Beispiel #1
0
    void OnJoinLobby(NetworkMessage netMessage)
    {
        var player = netMessage.ReadMessage <JoinLobbyMessage>();

        //lobbyManager.AddPlayer(new ConnectedPlayer(netMessage.conn.connectionId, player.playerName, player.isPlayer), netMessage.conn.connectionId);
        lobbyManager.AdjustPlayer(netMessage.conn.connectionId, player.playerName);

        //Send confirmation back to client
        var confirmation = new LobbyJoinedSuccessfulMessage();

        confirmation.successful         = true;
        confirmation.clientConnectionID = netMessage.conn.connectionId;
        NetworkServer.SendToClient(netMessage.conn.connectionId, AceMsgTypes.LobbyJoinedSuccessful, confirmation);

        //Send the updated lobby list to everyone connected
        var lobbyUpdate = new LobbyUpdateMessage();

        lobbyUpdate.connectedPlayers = lobbyManager.ParseToString();
        NetworkServer.SendToAll(AceMsgTypes.LobbyInfoUpdate, lobbyUpdate);
    }