Ejemplo n.º 1
0
        public override bool HandleMessage(GameClient session, ClientMessage message)
        {
            IncomingPacket incomingPacket;

            if (BasicUtilies.GetRevisionPacketManager(session.Revision).HandleIncoming(message.GetID(), out incomingPacket))
            {
                incomingPacket.Handle(session, message);

                try
                {
                    if (Skylight.GetConfig()["debug.incoming"] == "1")
                    {
                        Logging.WriteLine(string.Concat(new object[]
                        {
                            "[",
                            session.ID,
                            "] --> [",
                            message.GetID(),
                            "] ",
                            message.GetHeader(),
                            message.GetBody()
                        }));
                    }
                }
                catch
                {
                }
            }
            else
            {
                try
                {
                    if (Skylight.GetConfig()["show.unhandled.packets"] == "1")
                    {
                        Logging.WriteLine(string.Concat(new object[]
                        {
                            "[",
                            session.ID,
                            "] --> Packet dosen't exit: [",
                            message.GetID(),
                            "] ",
                            message.GetHeader(),
                            message.GetBody()
                        }));
                    }
                }
                catch
                {
                }
            }

            return(true);
        }
Ejemplo n.º 2
0
        public void HandleConnectionData(ref byte[] data)
        {
            if (data[0] == 64)
            {
                int pos = 0;
                while (pos < data.Length)
                {
                    try
                    {
                        int  MessageLength = Base64Encoding.DecodeInt32(new byte[] { data[pos++], data[pos++], data[pos++] });
                        uint MessageId     = Base64Encoding.DecodeUInt32(new byte[] { data[pos++], data[pos++] });

                        byte[] Content = new byte[MessageLength - 2];
                        for (int j = 0; j < Content.Length; j++)
                        {
                            Content[j] = data[pos++];
                        }
                        if (this.MessageHandler == null)
                        {
                            this.InitHandler();
                        }
                        ClientMessage Message = new ClientMessage(MessageId, Content);
                        if (Message != null)
                        {
                            try
                            {
                                if (int.Parse(PhoenixEnvironment.GetConfig().data["debug"]) == 1)
                                {
                                    Logging.WriteLine(string.Concat(new object[] { "[", ClientId, "] --> [", Message.Id, "] ", Message.Header, Message.GetBody() }));
                                }
                            }
                            catch
                            {
                            }
                            MessageEvent MessageHandler;
                            if (PhoenixEnvironment.GetPacketManager().Get(Message.Id, out MessageHandler))
                            {
                                MessageHandler.parse(this, Message);
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        Logging.LogException("Error: " + ex.ToString());
                        this.Disconnect();
                    }
                }
            }
            else
            {
                if (true)
                {
                    this.Connection.SendData(CrossdomainPolicy.GetXmlPolicy());
                    this.Connection.Dispose();
                }
            }
        }
Ejemplo n.º 3
0
        public void ParsePacket(ref byte[] bytes)
        {
            if (bytes[0] == 64)
            {
                int i = 0;

                while (i < bytes.Length)
                {
                    try
                    {
                        int num = Base64Encoding.DecodeInt32(new byte[]
                        {
                            bytes[i++],
                            bytes[i++],
                            bytes[i++]
                        });

                        uint uint_ = Base64Encoding.DecodeUInt32(new byte[]
                        {
                            bytes[i++],
                            bytes[i++]
                        });

                        byte[] array = new byte[num - 2];
                        for (int j = 0; j < array.Length; j++)
                        {
                            array[j] = bytes[i++];
                        }

                        if (this.ClientMessageHandler == null)
                        {
                            this.CreateClientMessageHandler();
                        }
                        ClientMessage @class = new ClientMessage(uint_, array);
                        if (@class != null)
                        {
                            try
                            {
                                if (int.Parse(GoldTree.GetConfig().data["debug"]) == 1)
                                {
                                    Logging.WriteLine(string.Concat(new object[]
                                    {
                                        "[",
                                        this.ID,
                                        "] --> [",
                                        @class.Id,
                                        "] ",
                                        @class.Header,
                                        @class.GetBody()
                                    }));
                                }
                            }
                            catch
                            {
                            }
                            Interface @interface;
                            if (GoldTree.GetPacketManager().Handle(@class.Id, out @interface))
                            {
                                try
                                {
                                    @interface.Handle(this, @class);
                                }
                                catch (Exception ex)
                                {
                                    Logging.LogException("Error: " + ex.ToString());
                                    this.method_12();
                                }
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        if (ex.GetType() == typeof(IndexOutOfRangeException))
                        {
                            return;
                        }
                        Logging.LogException("Error: " + ex.ToString());
                        this.method_12();
                    }
                }
            }
            else
            {
                if (true)                //Class13.Boolean_7)
                {
                    this.Connection.SendMessage(CrossdomainPolicy.GetXmlPolicy());
                    //this.Message1_0.SendData(GoldTree.GetDefaultEncoding().GetBytes(CrossdomainPolicy.GetXmlPolicy()));
                    this.Connection.Close();
                }
            }
        }
Ejemplo n.º 4
0
 public void method_13(ref byte[] byte_0)
 {
     if (byte_0[0] == 64)
     {
         int i = 0;
         while (i < byte_0.Length)
         {
             try
             {
                 int num = Base64Encoding.DecodeInt32(new byte[]
                 {
                     byte_0[i++],
                     byte_0[i++],
                     byte_0[i++]
                 });
                 uint uint_ = Base64Encoding.DecodeUInt32(new byte[]
                 {
                     byte_0[i++],
                     byte_0[i++]
                 });
                 byte[] array = new byte[num - 2];
                 for (int j = 0; j < array.Length; j++)
                 {
                     array[j] = byte_0[i++];
                 }
                 if (this.class17_0 == null)
                 {
                     this.method_4();
                 }
                 ClientMessage @class = new ClientMessage(uint_, array);
                 if (@class != null)
                 {
                     try
                     {
                         if (int.Parse(GoldTree.GetConfig().data["debug"]) == 1)
                         {
                             Logging.WriteLine(string.Concat(new object[]
                             {
                                 "[",
                                 this.UInt32_0,
                                 "] --> [",
                                 @class.Id,
                                 "] ",
                                 @class.Header,
                                 @class.GetBody()
                             }));
                         }
                     }
                     catch
                     {
                     }
                     Interface @interface;
                     if (GoldTree.smethod_10().Handle(@class.Id, out @interface))
                     {
                         @interface.Handle(this, @class);
                     }
                 }
             }
             catch (Exception ex)
             {
                 Logging.LogException("Error: " + ex.ToString());
                 this.method_12();
             }
         }
     }
     else
     {
         if (true)                //Class13.Boolean_7)
         {
             this.Message1_0.method_4(CrossdomainPolicy.GetXmlPolicy());
             this.Message1_0.Dispose();
         }
     }
 }