public async Task Connect(string host) { if (Connection != null) { await Connection.StopAsync(); await Connection.DisposeAsync(); } if (MessagingHub != null) { await MessagingHub.StopAsync(); await MessagingHub.DisposeAsync(); } Connection = new HubConnectionBuilder() .WithUrl($"{host}/RCDeviceHub") .AddMessagePackProtocol() .WithAutomaticReconnect() .Build(); MessagingHub = new HubConnectionBuilder() .WithUrl($"{host}/MessagingHub") .AddMessagePackProtocol() .WithAutomaticReconnect() .Build(); ApplyConnectionHandlers(); await Connection.StartAsync(); }