ibms-dome/ConsoleApp1/Program.cs

41 lines
1012 B
C#
Raw Normal View History

2022-10-14 16:08:54 +08:00
using FrontendWorkerService.HubServiceInterfaces;
using Microsoft.AspNetCore.SignalR.Client;
using System;
using System.Threading.Tasks;
namespace ConsoleApp1
{
class Program
{
static async Task Main(string[] args)
{
var connection = new HubConnectionBuilder()
.WithUrl(Strings.HubUrl)
.Build();
connection.On<DateTime>(Strings.Events.TimeSent, (dateTime) =>
{
Console.WriteLine(dateTime.ToString());
});
// Loop is here to wait until the server is running
while (true)
{
try
{
await connection.StartAsync();
break;
}
catch
{
await Task.Delay(1000);
}
}
Console.WriteLine("Client One listening. Hit Ctrl-C to quit.");
Console.ReadLine();
}
}
}