Пример #1
0
        public ServerPacket(SMSG msgID) : base(WORLDMSG.SERVER_MESSAGE)
        {
            Write((short)msgID);
            Write((short)0);             // GamePacket Data Len ( != WorldPacket len )

            m_serverMsgId = msgID;
        }
Пример #2
0
        public static void ToFile(BinReader data, SMSG msgID)
        {
            string msg = msgID.ToString() + " : \n";

            msg += ToString(data.ReadBytes((int)data.Length()), (int)data.Length());
            WriteToFile(msg);
        }
Пример #3
0
        public static void ToFile(BinWriter data, SMSG msgID)
        {
            string msg = msgID.ToString() + " : \n";

            msg += ToString(data.GetBuffer(), (int)data.BaseStream.Length);
            WriteToFile(msg);
        }
Пример #4
0
        public static BinWriter NewPacket(SMSG msgID)
        {
            BinWriter w = new BinWriter();

            w.Write((short)0);
            w.Write((uint)msgID);
            return(w);
        }
Пример #5
0
        public static BinWriter NewPacket(SMSG msgID)
        {
            DebugLogger.Logger.Log("LoginClient crafting packet " + msgID.ToString());
            BinWriter w = new BinWriter();

            w.Write((short)0);
            w.Write((ushort)msgID);
            return(w);
        }
Пример #6
0
        public void Send(SMSG msgID, BinWriter data)
        {
            ServerPacket pkg = new ServerPacket(msgID);

            pkg.Write(data.GetBuffer(), 0, (int)data.BaseStream.Length);
            pkg.Finish();
            pkg.AddDestination(m_character.ObjectId);
            WorldServer.Send(pkg);
        }
Пример #7
0
        public void Send(SMSG msgID, byte[] data, int index, int count)
        {
            ServerPacket pkg = new ServerPacket(msgID);

            pkg.Write(data, index, count);
            pkg.Finish();
            pkg.AddDestination(m_character.ObjectId);
            WorldServer.Send(pkg);
        }
Пример #8
0
 public void Send(SMSG msgID, byte[] data, int index, int count)
 {
     try {
         ServerPacket pkg = new ServerPacket(msgID);
         pkg.Write(data, index, count);
         pkg.Finish();
         pkg.AddDestination(m_character.ObjectId);
         WorldServer.Send(pkg);
     } catch (Exception exp) {
         DebugLogger.Logger.Log("", exp);
     }
 }
Пример #9
0
 public void Send(SMSG msgID, BinWriter data)
 {
     try {
         ServerPacket pkg = new ServerPacket(msgID);
         pkg.Write(data.GetBuffer(), 0, (int)data.BaseStream.Length);
         pkg.Finish();
         pkg.AddDestination(m_character.ObjectId);
         WorldServer.Send(pkg);
     } catch (Exception exp) {
         DebugLogger.Logger.Log("", exp);
     }
 }
        /*
         * internal bool processWorldServerData()
         * {
         *      if(m_client.PendingSendData)
         *              m_client.SendWork();
         *      if(m_client.Connected == false)
         *              return false;
         *      byte[] data;
         *      while((data = m_client.GetNextPacketData()) != null)
         *              OnWorldServerData(data);
         *      return m_client.Connected;
         * }*/

        private void OnWorldServerData(ClientBase c, byte[] data)
        {
            BinReader read = new BinReader(data);

            read.BaseStream.Position += 4;             // skip len
            WORLDMSG msgID = (WORLDMSG)read.ReadInt32();

            if (msgID == WORLDMSG.SERVER_MESSAGE)
            {
                SMSG smsg = (SMSG)read.ReadInt32();
                Console.WriteLine("WorldServer sent: " + smsg);
                int       len = read.ReadInt32();
                BinWriter pkg = LoginClient.NewPacket(smsg);
                if (len > 0)
                {
                    pkg.Write(read.ReadBytes(len));
                }
                while (read.BaseStream.Position < read.BaseStream.Length)
                {
                    uint        plrID  = read.ReadUInt32();
                    LoginClient client = LoginServer.GetLoginClientByCharacterID(plrID);
                    if (client == null)
                    {
                        Console.WriteLine("client missing for plrID " + plrID + " while sending " + smsg.ToString());
                    }
                    else
                    {
                        client.Send(pkg);
                    }
                }
            }
            else if (msgID == WORLDMSG.SCRIPT_MESSAGE)
            {
                LoginServer.Scripts.OnScriptMessage(read.ReadInt32(), read);
            }
            else
            {
                LoginPacketManager.HandlePacket(this, msgID, read);
            }
        }
Пример #11
0
 public MsgData()
 {
     stGSPkg = new SMSG();
 }
Пример #12
0
 public ServerPacket(SMSG msgID) : base(WORLDMSG.SERVER_MESSAGE)
 {
     Write((int)msgID);
     Write(0);             // GamePacket Data Len ( != WorldPacket len )
 }
Пример #13
0
 public static void ToFile(byte[] buffer, SMSG msgID)
 {
     WriteToFile(ToString(buffer, buffer.Length));
 }