Coding the game

In this section, we will implement our gaming solution. The end output will be the working two-player Tic-Tac-Toe game. We will do the coding in steps for ease of understanding:

  1.  In the Startup class, we modify the ConfigureServices method to add SignalR to the container, by writing the following code:
//// Adds SignalR to the services container. services.AddSignalR();
  1. In the Configure method of the same class, we configure the pipeline to use SignalR and intercept and wire up the request containing gameHub to our SignalR hub that we will be creating with the following code:
//// Use - SignalR & let it know to intercept and map any request having gameHub. app.UseSignalR(routes =>  {        routes.MapHub<GameHub>("gameHub");

Get .NET Core 2.0 By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.