Example #1
0
        /// <summary>
        /// Update this server instance with information from the supplied packet
        /// </summary>
        /// <param name="data"></param>
        public void Update(ServerInfoPacket data)
        {
            this.Active         = true;
            this.Name           = data.Name;
            this.Port           = data.Port;
            this.Map            = data.Map;
            this.GameType       = data.GameType;
            this.MaxPlayers     = data.MaxPlayers;
            this.CurrentPlayers = data.NumPlayers;
            this.Properties     = data.Info;
            this.Players        = data.Players;

            this.LastUpdate = DateTime.Now;
            this.listEntry  = new ServerListEntry(Address, (ushort)Port, (ushort)QueryPort, Name, Map, GameType, (byte)CurrentPlayers, (byte)MaxPlayers, Flags);
        }
Example #2
0
        /// <summary>
        /// Update this server with information from a remote master
        /// </summary>
        /// <param name="active">True if the server is active (gamestate has been received)</param>
        /// <param name="address">IP address of the server</param>
        /// <param name="cdkey">CD key hash of the server</param>
        /// <param name="name">Name of the server</param>
        /// <param name="country">Server's country</param>
        /// <param name="locale">Server's locale (eg. int)</param>
        /// <param name="port">Server listen port</param>
        /// <param name="queryport">Server's query port</param>
        /// <param name="map">Current map</param>
        /// <param name="gametype">Current game type</param>
        /// <param name="maxplayers">Max connections</param>
        /// <param name="currentplayers">Current player count</param>
        /// <param name="properties">Array of server properties</param>
        /// <param name="players">List of players on the server</param>
        public void Update(bool active, IPAddress address, string cdkey, string name, string country, string locale, int port, int queryport, string map, string gametype, int maxplayers, int currentplayers, Dictionary <string, string> properties, List <Player> players)
        {
            this.Active         = active;
            this.Address        = address;
            this.CDKey          = cdkey;
            this.Name           = name;
            this.Country        = country;
            this.Locale         = locale;
            this.Port           = port;
            this.queryPort      = queryport;
            this.Map            = map;
            this.GameType       = gametype;
            this.MaxPlayers     = maxplayers;
            this.CurrentPlayers = currentplayers;
            this.Properties     = properties;
            this.Players        = players;

            this.LastUpdate = DateTime.Now;
            this.listEntry  = new ServerListEntry(Address, (ushort)Port, (ushort)QueryPort, Name, Map, GameType, (byte)CurrentPlayers, (byte)MaxPlayers, Flags);
        }
Example #3
0
        /// <summary>
        /// Update this server instance with information from the supplied heartbeat packet
        /// </summary>
        /// <param name="data"></param>
        public void Update(byte packetType, UDPPacket data)
        {
            switch ((UDPServerQueryClient.UDPServerQueryType)packetType)
            {
            case UDPServerQueryClient.UDPServerQueryType.Basic:
                /* this.serverID = */ data.PopInt();
                /* this.serverIP = */ data.PopString();
                this.Port = data.PopInt();
                /* this.QueryPort = */ data.PopInt();
                this.Name           = data.PopString();
                this.Map            = data.PopString();
                this.GameType       = data.PopString();
                this.CurrentPlayers = data.PopInt();
                this.MaxPlayers     = data.PopInt();
                /* this.Ping = */ data.PopInt();

                this.Active     = true;
                this.LastUpdate = DateTime.Now;
                this.listEntry  = new ServerListEntry(Address, (ushort)Port, (ushort)QueryPort, Name, Map, GameType, (byte)CurrentPlayers, (byte)MaxPlayers, Flags);

                break;

            case UDPServerQueryClient.UDPServerQueryType.GameInfo:
                Properties = data.PopKeyValues();

                break;

            case UDPServerQueryClient.UDPServerQueryType.PlayerInfo:
                Players.Clear();

                while (!data.EOF)
                {
                    Players.Add(new Player(this, data, ""));
                }

                break;
            }
        }