예제 #1
0
        private void HandlePlayerListReq(MsgPlayerListReq message)
        {
            var channel = message.MsgChannel;
            var players = GetAllPlayers().ToArray();
            var netMsg  = channel.CreateNetMessage <MsgPlayerList>();

            var list = new List <PlayerState>();

            foreach (var client in players)
            {
                if (client == null)
                {
                    continue;
                }

                var info = new PlayerState
                {
                    Index  = client.Index,
                    Uuid   = client.ConnectedClient.ConnectionId,
                    Name   = client.Name,
                    Status = client.Status,
                    Ping   = client.ConnectedClient.Ping
                };
                list.Add(info);
            }
            netMsg.Plyrs    = list;
            netMsg.PlyCount = (byte)list.Count;

            channel.SendMessage(netMsg);

            // client session is complete
            var session = GetSessionByChannel(channel);

            session.Status = SessionStatus.Connected;
        }
예제 #2
0
        private void HandlePlayerListReq(MsgPlayerListReq message)
        {
            var channel = message.MsgChannel;
            var players = GetAllPlayers().ToArray();
            var netMsg  = channel.CreateNetMessage <MsgPlayerList>();

            // client session is complete, set their status accordingly.
            // This is done before the packet is built, so that the client
            // can see themselves Connected.
            var session = GetSessionByChannel(channel);

            session.Status = SessionStatus.Connected;

            var list = new List <PlayerState>();

            foreach (var client in players)
            {
                if (client == null)
                {
                    continue;
                }

                var info = new PlayerState
                {
                    SessionId = client.SessionId,
                    Name      = client.Name,
                    Status    = client.Status,
                    Ping      = client.ConnectedClient.Ping
                };
                list.Add(info);
            }
            netMsg.Plyrs    = list;
            netMsg.PlyCount = (byte)list.Count;

            channel.SendMessage(netMsg);
        }