Esempio n. 1
0
        private void ParseData(byte[] buffer)
        {
            ReplyStream stream = new ReplyStream(new MemoryStream(buffer));

            if (stream.ReadInt() == -1)
            {
                HandleMessage(stream.ReadByte(), stream);
            }
        }
Esempio n. 2
0
 private void HandleChallenge(ReplyStream stream)
 {
     byte[] buff = new byte[9];
     for (int i = 0; i < 4; i++)
     {
         buff[i] = 0xFF;
     }
     buff[4] = 0x55;
     for (int i = 5; i < 9; i++)
     {
         buff[i] = stream.ReadByte();
     }
     _socket.Send(buff, buff.Length);
 }
Esempio n. 3
0
        private void HandleInformation(ReplyStream stream)
        {
            stream.ReadByte();
            string name            = stream.ReadString();
            string map             = stream.ReadString();
            string gameDirectory   = stream.ReadString();
            string gameDescription = stream.ReadString();
            short  applicationId   = stream.ReadShort();
            int    playersCount    = stream.ReadUnsignedByte();
            int    maximumPlayers  = stream.ReadUnsignedByte();
            int    botCount        = stream.ReadByte();
            String type            = "";

            switch ((int)stream.ReadByte())
            {
            case 'd': type = "Dedicated"; break;

            case 'l': type = "Listen"; break;

            case 'p': type = "TV"; break;
            }

            String os = "";

            switch ((int)stream.ReadByte())
            {
            case 'l': os = "Linux"; break;

            case 'w': os = "Windows"; break;
            }
            bool   passwordRequired = stream.ReadByte() == 1;
            bool   vacSecure        = stream.ReadByte() == 1;
            String version          = stream.ReadString();

            String overall = name + " " + playersCount + "/" + maximumPlayers + " " + map;

            NameValueCollection list = new NameValueCollection(5)
            {
                ["name"]           = name,
                ["map"]            = map,
                ["playersCount"]   = playersCount.ToString(),
                ["maximumPlayers"] = maximumPlayers.ToString(),
                ["type"]           = type,
                ["os"]             = os
            };

            _handler.HandleServerInfo(list);
        }