Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="packet"></param>
        /// <param name="messageNumber"></param>
        public void Parse(Client client, ref byte[] packet, int messageNumber)
        {
            switch (messageNumber)
            {
            case 27:
                // client connected, lets send first message (not compressed)
            {
                Byte[] connected = new byte[]
                {
                    0xDF, 0xDF,
                    0x7F, 0x00,
                    0x00, 0x01,
                    0x00, 0x10,
                    0x03, 0x00, 0x00, 0x00,
                    0x00, 0x00, 0x00, 0x00
                };
                client.Send(ref connected);

                // and off we go to ClientConnected
                ClientConnected tmp_ClientConnected = new ClientConnected();
                tmp_ClientConnected.Read(ref packet, client);
            }
            break;

            default:
                client.Server.Warning(client, "Client sent unknown SystemMessage {0:x8}", messageNumber.ToString());
                break;
            }
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="client"></param>
        /// <param name="packet"></param>
        /// <param name="messageNumber"></param>
        public void Parse(Client client, byte[] packet, int messageNumber)
        {
            switch (messageNumber)
            {
            case 27:
                // client connected, lets send first message (not compressed)
            {
                Byte[] connected = new byte[]
                {
                    0xDF, 0xDF, 0x7F, 0x00, 0x00, 0x01, 0x00, 0x10, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                    0x00
                };
                client.Send(connected);

                // and off we go to ClientConnected
                ClientConnected tmpClientConnected = new ClientConnected();
                tmpClientConnected.Read(packet, client);
            }
            break;

            default:
                client.Server.Warning(client, "Client sent unknown SystemMessage {0:x8}", messageNumber.ToString());
                TextWriter tw = new StreamWriter(
                    "System Message Debug output.txt", true, Encoding.GetEncoding("windows-1252"));
                tw.WriteLine("System Message " + messageNumber.ToString());
                string line = "";
                string asc  = "";
                foreach (byte b in packet)
                {
                    line = line + b.ToString("X2") + " ";
                    if ((b >= 32) && (b <= 127))
                    {
                        asc = asc + (Char)b;
                    }
                    else
                    {
                        asc = asc + ".";
                    }
                    if (asc.Length == 16)
                    {
                        tw.WriteLine(line + asc);
                        line = "";
                        asc  = "";
                    }
                }
                if (line != "")
                {
                    tw.WriteLine(line.PadRight(16 * 3), asc);
                }
                tw.Close();
                break;
            }
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="client"></param>
        /// <param name="packet"></param>
        /// <param name="messageNumber"></param>
        public void Parse(Client client, byte[] packet, int messageNumber)
        {
            switch (messageNumber)
            {
                case 27:
                    // client connected, lets send first message (not compressed)
                    {
                        Byte[] connected = new byte[]
                            {
                                0xDF, 0xDF, 0x7F, 0x00, 0x00, 0x01, 0x00, 0x10, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                                0x00
                            };
                        client.Send(connected);

                        // and off we go to ClientConnected
                        ClientConnected tmpClientConnected = new ClientConnected();
                        tmpClientConnected.Read(packet, client);
                    }
                    break;
                default:
                    client.Server.Warning(client, "Client sent unknown SystemMessage {0:x8}", messageNumber.ToString());
                    TextWriter tw = new StreamWriter(
                        "System Message Debug output.txt", true, Encoding.GetEncoding("windows-1252"));
                    tw.WriteLine("System Message " + messageNumber.ToString());
                    string line = "";
                    string asc = "";
                    foreach (byte b in packet)
                    {
                        line = line + b.ToString("X2") + " ";
                        if ((b >= 32) && (b <= 127))
                        {
                            asc = asc + (Char)b;
                        }
                        else
                        {
                            asc = asc + ".";
                        }
                        if (asc.Length == 16)
                        {
                            tw.WriteLine(line + asc);
                            line = "";
                            asc = "";
                        }
                    }
                    if (line != "")
                    {
                        tw.WriteLine(line.PadRight(16 * 3), asc);
                    }
                    tw.Close();
                    break;
            }
        }