public MatchLobbyContext MakeLobbyContext() { if (IsHost) { var lobby = new MatchLobby(GameData.Scenarios.First()); lobby.ApplyAction(new AddPlayerAction(Player)); var chat = new Chat(); Server.MessageAdapter = new NonMatchMessageSerializer(); Server.RPCHandler = new RPCHandler().Install( new LobbyServerLayer(lobby, ConnectionCache), new ChatServerLayer(chat, ConnectionCache)); lobby.OnActionApplied += (sender, e) => Server.Broadcast(new ApplyLobbyActionRequest(e.Value)); chat.OnActionApplied += (sender, e) => Server.Broadcast(new ApplyChatActionRequest(e.Value)); return(new MatchLobbyContext(Server, ConnectionCache, lobby, chat)); } else { var chat = new Chat(); Client.MessageAdapter = new NonMatchMessageSerializer(); var lobbyLayer = new LobbyLayer(); var handler = new RPCHandler().Install(lobbyLayer, new ChatLayer(chat)); Client.RPCHandler = handler; if (Client.Call( new ApplyLobbyActionRequest(new AddPlayerAction(Player))).Get <BooleanResponse>().Value) { MatchLobby lobby = Client.Call(new GetLobbyRequest()).Get <GetLobbyResponse>().Lobby; lobbyLayer.Lobby = lobby; return(new MatchLobbyContext(Client, lobby, chat)); } return(null); } }
public bool SetScenario(Scenario Scenario) { return(_Lobby.ApplyAction(new SetScenarioAction(Scenario))); }