Creating a SignalR client
As a simple client receiving real-time information, all we need is a console application that connects to live-service
. By doing this, it’s simple to implement this functionality with any other client.
Start by creating a console project:
dotnet new console -o LiveTestClient
The Microsoft.AspNetCore.SignalR.Client
NuGet package needs to be added to call a SignalR service. We must also add Microsoft.Extensions.Hosting
for the DI container and CNinnovation.Codebreaker.BackendModels
with the GameSummary
type.
Create the LiveClient
class, which will communicate with the SignalR service:
LiveTestClient/LiveClient.cs
internal class LiveClient(IOptions<LiveClientOptions> options) : IAsyncDisposable { // code removed for brevity } public class LiveClientOptions { public string? LiveUrl { get; set; } }
The LiveClient
class specifies a constructor with IOptions<LiveClientOptions>
. This will be configured...