public Result Join(string username) { JoinGameAction gameAction = new JoinGameAction(_userContextProvider.UserId, username); GoFishGame game = _gameAccessor.Game; Result result = _gameManager.PerformAction(gameAction, ref game); return(result); }
public async Task Handle(JoinGameAction action, IDispatcher dispatcher) { if (ServerState.Value.Status != ServerStatus.Connected || ServerState.Value.GameServer is null) { return; } var response = await ServerState.Value.GameServer.JoinGame(action.GameCode.ToUpper(), action.Username.Trim()); if (response is not null && response.ErrorMessage is not null) { dispatcher.Dispatch(new GameJoinedFailedEvent(response.ErrorMessage)); } }
public void OnRemoteConnection() { clients = adapter.clients(); if (isHost) { if (clients.Length > 1) { JoinGameAction join = new JoinGameAction(); join.player = clients.Length - 1; join.host = isHost; join.perform(); adapter.send(join.Serialize(), clients[clients.Length - 1]); } } }