public async Task Connect() { _hubConnection = new HubConnectionBuilder().WithUrl(_hubUri).Build(); _hubConnection.On(GameEvents.GameSessionStarted, () => GameSessionStarted?.Invoke()); _hubConnection.On <bool>(nameof(IsSessionOpen), (isOpen) => IsSessionOpen?.Invoke(isOpen)); _hubConnection.On(GameEvents.PlayerCreated, () => PlayerCreated?.Invoke()); _hubConnection.On <ICollection <string> >(nameof(IncomingPlayers), (players) => IncomingPlayers?.Invoke(players)); _hubConnection.On(GameEvents.GameStarted, () => GameStarted?.Invoke()); _hubConnection.On <int>(GameEvents.TimeElapsed, countDownSeconds => TimeElapsed?.Invoke(countDownSeconds)); _hubConnection.On(GameEvents.GameStopped, () => GameStopped?.Invoke()); _hubConnection.On <int>(GameEvents.RightAnswer, newScore => SentRightAnswer?.Invoke(newScore)); _hubConnection.On <int>(GameEvents.WrongAnswer, newScore => SentWrongAnswer?.Invoke(newScore)); _hubConnection.On(GameEvents.RoundEnded, () => RoundEnded?.Invoke()); _hubConnection.On <string>(GameEvents.Question, question => QuestionSent?.Invoke(question)); _hubConnection.On <AnswerAndPlayers>(GameEvents.AnswerAndPlayers, answerAndPlayers => GotAnswerAndPlayers?.Invoke(answerAndPlayers)); _hubConnection.On(GameEvents.NextRoundStarted, () => NextRoundStarted?.Invoke()); await _hubConnection.StartAsync(); }