public async Task JoinToGameTable(JoinToGameTableParams @params) { try { var result = _gameTableService.Join(@params.GameTableId, Context.User.GetUserId()); await AddToGroup(@params.GameTableId.ToString(), Context.ConnectionId); await NotifyAboutPlayerJoined(@params.GameTableId, result); await Clients.Caller.ReceiveJoinResult(new ReceiveJoinResultParams() { Succeeded = true, RequestId = @params.RequestId, PlaceNumber = result.PlaceNumber }); } catch (Exception ex) { _logger.LogError(ex, $"Ошибка присоединения к игровому столу. Игрок с Id = {Context.User.GetUserId()}"); await Clients.Caller.ReceiveJoinResult(new ReceiveJoinResultParams() { Succeeded = false, RequestId = @params.RequestId }); } }
public Promise <ReceiveJoinResultParams> JoinToGameTable(JoinToGameTableParams @params) { if (_isDisposed) { throw new ObjectDisposedException("Ресурсы объекта были освобождены"); } if (_hubConnection == null) { throw new Exception("Подключение еще не было создано"); } if (_hubConnection.State != HubConnectionState.Connected) { throw new Exception($"Подключение еще не установлено. Статус - {_hubConnection.State}"); } var promise = new Promise <ReceiveJoinResultParams>(@params.RequestId, () => { _hubConnection.InvokeAsync(nameof(IMainHubApi.JoinToGameTable), @params); }); ReceivedJoinResult += promise.OnCopleted; return(promise); }