예제 #1
0
        /// <summary>
        /// Constructs the list of servers, based on the packet received from usgn.de
        /// </summary>
        /// <param name="ps"></param>
        /// <returns></returns>
        private int OnUsgnServerPacket(PacketStream ps)
        {
            short num_servers = ps.ReadShort();

            for (int i = 0; i < num_servers; i++)
            {
                byte[] ipdata = new byte[4];
                for (int j = 0; j < 4; j++)
                {
                    ipdata[3 - j] = ps.ReadByte();
                }

                IPAddress ipa  = new IPAddress(ipdata);
                ushort    port = (ushort)ps.ReadShort();
                RequestServerInformation(ipa, port);
                ServerInformation svi = new ServerInformation(ipa, port);
                serverList.Add(svi);
            }
            return(num_servers);
        }
예제 #2
0
        /// <summary>
        /// Function determines what happens when information about a server is returned
        /// </summary>
        /// <param name="ps"></param>
        /// <param name="svi"></param>
        /// <returns></returns>
        private int OnServerInformationReceive(PacketStream ps, ServerInformation svi)
        {
            byte cmd = ps.ReadByte();

            if (cmd == 1)
            {
                ps.ReadByte(); // dunno?
                svi.Name           = ps.ReadString();
                svi.Map            = ps.ReadString();
                svi.CurrentClients = ps.ReadByte();
                svi.MaxClients     = ps.ReadByte();
                byte gamemode = ps.ReadByte();

                AddServerToGrid(svi);
            }
            else if (cmd == 5)
            {
                //player info
            }
            return(0);
        }
예제 #3
0
        /// <summary>
        /// Constructs the list of servers, based on the packet received from usgn.de
        /// </summary>
        /// <param name="ps"></param>
        /// <returns></returns>
        private int OnUsgnServerPacket(PacketStream ps)
        {
            short num_servers = ps.ReadShort();
            for (int i = 0; i < num_servers; i++)
            {
                byte[] ipdata = new byte[4];
                for (int j = 0;j < 4; j++) { ipdata[3-j] = ps.ReadByte(); }

                IPAddress ipa = new IPAddress(ipdata);
                ushort port = (ushort)ps.ReadShort();
                RequestServerInformation(ipa, port);
                ServerInformation svi = new ServerInformation(ipa,port);
                serverList.Add(svi);

            }
            return num_servers;
        }
예제 #4
0
 private void AddServerToGrid(ServerInformation svi)
 {
     if (dgv.InvokeRequired)
         dgv.Invoke(new d_serverToGrid(this.AddServerToGrid), svi);
     else
         dgv.Rows.Add(svi.ToStringArray());
 }
예제 #5
0
        /// <summary>
        /// Function determines what happens when information about a server is returned
        /// </summary>
        /// <param name="ps"></param>
        /// <param name="svi"></param>
        /// <returns></returns>
        private int OnServerInformationReceive(PacketStream ps,ServerInformation svi)
        {
            byte cmd = ps.ReadByte();
            if (cmd == 1)
            {
                ps.ReadByte(); // dunno?
                svi.Name = ps.ReadString();
                svi.Map = ps.ReadString();
                svi.CurrentClients = ps.ReadByte();
                svi.MaxClients = ps.ReadByte();
                byte gamemode = ps.ReadByte();

                AddServerToGrid(svi);
            }
            else if (cmd == 5)
            {
                //player info
            }
            return 0;
        }