Esempio n. 1
0
 private protected override unsafe void PacketEvent(NetAddress address, Message msg)
 {
     fixed(byte *b = msg.Data)
     {
         if (msg.CurSize >= 4 && *(int *)b == -1)
         {
             msg.BeginReading(true);
             msg.ReadLong();
             string s       = msg.ReadStringLineAsString();
             var    command = new Command(s);
             string c       = command.Argv(0);
             if (string.Compare(c, "infoResponse", true) == 0)
             {
                 this.ServerInfoPacket(address, msg);
             }
             else if (string.Compare(c, "statusResponse", true) == 0)
             {
                 this.ServerStatusResponse(address, msg);
             }
             else if (string.Compare(c, 0, "getserversResponse", 0, 18, false) == 0)
             {
                 this.ServersResponsePacket(address, msg);
             }
         }
     }
 }
Esempio n. 2
0

        
Esempio n. 3
0
 public NetChannel(NetSystem net, NetAddress address, int qport, int maxMessageLength)
 {
     this.net              = net;
     this.Address          = address;
     this.qport            = qport;
     this.maxMessageLength = maxMessageLength;
     this.fragmentBuffer   = new byte[this.maxMessageLength];
     this.unsentBuffer     = new byte[this.maxMessageLength];
 }
Esempio n. 4
0
 internal void OutOfBandPrint(NetAddress address, string data)
 {
     byte [] msg = new byte[Message.MaxMsgLen];
     msg[0] = unchecked ((byte)-1);
     msg[1] = unchecked ((byte)-1);
     msg[2] = unchecked ((byte)-1);
     msg[3] = unchecked ((byte)-1);
     byte [] dataMsg = Common.Encoding.GetBytes(data);
     dataMsg.CopyTo(msg, 4);
     this.net.SendPacket(dataMsg.Length + 4, msg, address);
 }
Esempio n. 5
0
        private void ServerStatusResponse(NetAddress address, Message msg)
        {
            var info = new InfoString(msg.ReadStringLineAsString());

            if (this.globalServers.ContainsKey(address))
            {
                var serverInfo = this.globalServers[address];
                this.BrowserHandler.HandleStatusResponse(serverInfo, info);
                this.serverRefreshTimeout = Common.Milliseconds + ServerBrowser.RefreshTimeout;
            }
        }
Esempio n. 6
0
        private protected void GetPacket()
        {
            var        netmsg  = new Message(packetReceived, sizeof(byte) * Message.MaxMsgLen);
            NetAddress address = null;

            while (this.net.GetPacket(ref address, netmsg))
            {
                if ((uint)netmsg.CurSize <= netmsg.MaxSize)
                {
                    this.PacketEvent(address, netmsg);
                }
                Common.MemSet(netmsg.Data, 0, sizeof(byte) * netmsg.MaxSize);
            }
        }
Esempio n. 7
0
        private void ServerStatusResponse(NetAddress address, Message msg)
        {
            var infoString = new InfoString(msg.ReadStringLineAsString());

            if (this.globalServers.ContainsKey(address))
            {
                var serverInfo = this.globalServers[address];
                if (infoString["version"].Contains("v1.03"))
                {
                    serverInfo.Version = ClientVersion.JO_v1_03;
                }
                this.serverRefreshTimeout = Common.Milliseconds + ServerBrowser.RefreshTimeout;
            }
        }
Esempio n. 8
0
        private unsafe void ServersResponsePacket(NetAddress address, Message msg)
        {
            fixed(byte *b = msg.Data)
            {
                byte *buffptr = b;
                byte *buffend = buffptr + msg.CurSize;

                do
                {
                    if (*buffptr == 92)                       //'\\'
                    {
                        break;
                    }
                    buffptr++;
                } while (buffptr < buffend);
                while (buffptr + 1 < buffend)
                {
                    if (*buffptr != 92)                       //'\\'
                    {
                        break;
                    }
                    buffptr++;
                    byte [] ip = new byte[4];
                    if (buffend - buffptr < ip.Length + sizeof(ushort) + 1)
                    {
                        break;
                    }
                    for (int i = 0; i < ip.Length; i++)
                    {
                        ip[i] = *buffptr++;
                    }
                    int port = (*buffptr++) << 8;
                    port += *buffptr++;
                    var serverInfo = new ServerInfo()
                    {
                        Address = new NetAddress(ip, (ushort)port),
                        Start   = Common.Milliseconds
                    };
                    this.globalServers[serverInfo.Address] = serverInfo;
                    this.OutOfBandPrint(serverInfo.Address, "getinfo xxx");
                    if (*buffptr != 92 && *buffptr != 47)                       //'\\' '/'
                    {
                        break;
                    }
                }
            }
        }
Esempio n. 9
0
        internal void OutOfBandData(NetAddress address, string data, int length)
        {
            byte [] msg = new byte[this.NetHandler.MaxMessageLength * 2];
            msg[0] = 0xff;
            msg[1] = 0xff;
            msg[2] = 0xff;
            msg[3] = 0xff;
            byte [] dataMsg = Common.Encoding.GetBytes(data);
            dataMsg.CopyTo(msg, 4);
            var mbuf = new Message(msg, msg.Length)
            {
                CurSize = length + 4
            };

            Huffman.Compress(mbuf, 12);
            this.net.SendPacket(mbuf.CurSize, mbuf.Data, address);
        }
Esempio n. 10
0
        private void ServerInfoPacket(NetAddress address, Message msg)
        {
            var infoString = new InfoString(msg.ReadStringAsString());

            if (this.globalServers.ContainsKey(address))
            {
                var serverInfo = this.globalServers[address];
                if (serverInfo.InfoSet)
                {
                    return;
                }
                serverInfo.Ping = (int)(Common.Milliseconds - serverInfo.Start);
                serverInfo.SetInfo(infoString);
                if (serverInfo.Protocol == ProtocolVersion.Protocol15)
                {
                    this.OutOfBandPrint(serverInfo.Address, "getstatus");
                }
                this.serverRefreshTimeout = Common.Milliseconds + ServerBrowser.RefreshTimeout;
            }
        }
Esempio n. 11
0

        
Esempio n. 12
0
 public NetChannel(NetSystem net, NetAddress address, int qport)
 {
     this.net     = net;
     this.Address = address;
     this.qport   = qport;
 }
Esempio n. 13
0
 private protected abstract void PacketEvent(NetAddress address, Message msg);
Esempio n. 14
0

        
Esempio n. 15
0
 public NetAddress(NetAddress address)
 {
     this.IP = new byte[address.IP.Length];
     Array.Copy(address.IP, this.IP, address.IP.Length);
     this.Port = address.Port;
 }