Код: Выделить всё
using Microsoft.AspNetCore.SignalR.Client;
Console.WriteLine("Connecting to Hub...");
var hubConnection = new HubConnectionBuilder().WithUrl("https://localhost:7178/queueHub").Build();
hubConnection.Closed += async (error) =>
{
Console.WriteLine("Connection closed. Reconnecting...");
await Task.Delay(new Random().Next(0, 5) * 1000);
await hubConnection.StartAsync();
};
hubConnection.On("notifyQueuePosition", (queueCount) =>
{
Console.WriteLine($"Message received from server: {queueCount}");
});
try
{
await hubConnection.StartAsync();
Console.WriteLine("Connected to SignalR Hub.");
await hubConnection.InvokeAsync("JoinQueue", "fj294ij29r8jv09258jwr0fj2508f2trvjh2");
}
catch (Exception ex)
{
Console.WriteLine($"Error connecting to SignalR Hub: {ex.Message}");
}
Console.ReadLine();
"await _queueHub. Clients.All.SendAsync("notifyQueuePosition",queueCount);"
Проблема в том, что счетчик очереди не печатается на консоли моего клиента.
Подробнее здесь: https://stackoverflow.com/questions/782 ... e-position