Creating a SignalR service
In this chapter, we’ll create a new service that offers real-time information to return games that are played to every connected client. Figure 13.1 shows how the services of the solution collaborate:
Figure 13.1 – Codebreaker services
The game-apis
service has existed since Chapter 2. The client of game-apis
invokes the REST API to start games and set moves. What’s new is Codebreaker’s live-service
. This service offers a simple REST API that’s invoked by the game-apis
service every time a game completes. The main functionality of this service makes use of ASP.NET Core SignalR to offer real-time information to all connected clients. Clients need to subscribe before they can receive game completion messages.
What’s offered by SignalR? As connections can never be started from a server to a client, and this is also true of SignalR, a client needs to connect to the SignalR service and...