Example #1
0
        public MaplePacket(CommunicationType pType, ushort pOpcode)
        {
            Logger.PWrite("{0}[OUT]", Environment.NewLine);

            _memoryStream = new MemoryStream();
            _binWriter    = new BinaryWriter(_memoryStream);
            WriteByte((byte)pType);
            WriteUShort(pOpcode);
        }
Example #2
0
        public MaplePacket(ushort pOpcode)
        {
            Logger.PWrite("{0}[OUT]", Environment.NewLine);

            _memoryStream = new MemoryStream();
            _binWriter    = new BinaryWriter(_memoryStream);

            WriteUShort(pOpcode);
        }
Example #3
0
 public void Skip(int pAmount)
 {
     if (pAmount + _memoryStream.Position > Length)
     {
         throw new Exception("!!! Cannot skip more bytes than there's inside the buffer!");
     }
     Logger.PWrite("[SKIP]");
     LogPacketData(pAmount);
     _memoryStream.Position += pAmount;
 }
Example #4
0
        public void WriteHexString(string pInput)
        {
            pInput = pInput.Replace(" ", "");
            if (pInput.Length % 2 != 0)
            {
                throw new Exception("Hex String is incorrect (size)");
            }


            for (int i = 0; i < pInput.Length; i += 2)
            {
                WriteByte(byte.Parse(pInput.Substring(i, 2), System.Globalization.NumberStyles.HexNumber));
            }

            Logger.PWrite("[HEX INPUT]");
            LogPacketData(pInput.Length % 2);
        }
Example #5
0
        private void LogPacketData(int pLength)
        {
            if (!Logger.PacketLogging)
            {
                return;
            }

            int curpos = Position + (_binWriter != null ? -pLength : 0);

            byte[] tmp2 = ToArray();
            string tmp  = "";

            for (int i = 0; i < pLength; i++)
            {
                tmp += string.Format("{0:X2} ", tmp2[curpos + i]);
            }
            tmp = tmp.TrimEnd();

            Logger.PWrite(" [{0}]", tmp);

            _memoryStream.Position = curpos + (_binWriter != null ? pLength : 0);
        }
Example #6
0
 public byte[] ReadLeftoverBytes()
 {
     Logger.PWrite("[LEFTOVER]");
     LogPacketData(Length - Position);
     return(ReadBytes(Length - Position));
 }