Example #1
0
        public JoinedLobby(LobbyDataPacket data, IClientSocket connection)
        {
            _connection = connection;
            Data        = data;
            connection.SetHandler((short)MstMessageCodes.LobbyMemberPropertyChanged, HandleMemberPropertyChanged);
            connection.SetHandler((short)MstMessageCodes.LeftLobby, HandleLeftLobbyMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyChatMessage, HandleLobbyChatMessageMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyMemberJoined, HandleLobbyMemberJoinedMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyMemberLeft, HandleLobbyMemberLeftMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyStateChange, HandleLobbyStateChangeMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyStatusTextChange, HandleLobbyStatusTextChangeMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyMemberChangedTeam, HandlePlayerTeamChangeMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyMemberReadyStatusChange, HandleLobbyMemberReadyStatusChangeMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyMasterChange, HandleLobbyMasterChangeMsg);
            connection.SetHandler((short)MstMessageCodes.LobbyPropertyChanged, HandleLobbyPropertyChanged);

            Properties = data.LobbyProperties;
            Members    = data.Players;
            Teams      = data.Teams;
        }
Example #2
0
        public LobbyDataPacket GenerateLobbyData(LobbyUserPeerExtension user)
        {
            var info = new LobbyDataPacket
            {
                LobbyType           = Type ?? "",
                GameMaster          = GameMaster != null ? GameMaster.Username : "",
                LobbyName           = Name,
                LobbyId             = Id,
                LobbyProperties     = propertiesList.ToDictionary(),
                Members             = membersByUsernameList.Values.ToDictionary(m => m.Username, GenerateMemberData),
                Teams               = teamsList.Values.ToDictionary(t => t.Name, t => t.GenerateData()),
                Controls            = controls,
                LobbyState          = State,
                MaxPlayers          = MaxPlayers,
                EnableTeamSwitching = Config.EnableTeamSwitching,
                EnableReadySystem   = Config.EnableReadySystem,
                EnableManualStart   = Config.EnableManualStart,
                CurrentUserUsername = TryGetUsername(user.Peer)
            };

            return(info);
        }