private async void OpenHubConnection() { if (_connection.State == HubConnectionState.Disconnected) { _connection.On <StateValueKey, StateValue>("ValueChanged", StateValueChanged); try { await _connection.StartAsync(); if (_connection.State == HubConnectionState.Connected) { HubConnectionOpened?.Invoke(); } } catch (Exception) { HubConnectionClosed?.Invoke(); } } }
private Task ConnectionClosed(Exception arg) { HubConnectionClosed?.Invoke(); InitiateTimerToTryToReconnectOnServer(); return(Task.CompletedTask); }