示例#1
0
        private void ManipulateBuffer()
        {
            while (m_offset > HeaderSize) //header room
            {
                int packetSize = MapleCipher.GetPacketLength(m_packet);

                if (m_offset < packetSize + HeaderSize) //header + packet room
                {
                    break;
                }

                byte[] packetBuffer = new byte[packetSize];
                Buffer.BlockCopy(m_packet, 4, packetBuffer, 0, packetSize); //copy packet

                m_recvCipher.Transform(packetBuffer);                       //decrypt

                m_offset -= packetSize + HeaderSize;                        //fix len

                if (m_offset > 0)                                           //move reamining bytes
                {
                    Buffer.BlockCopy(m_packet, packetSize + HeaderSize, m_packet, 0, m_offset);
                }

                OnPacket(packetBuffer);
            }
        }
示例#2
0
        public Session(Socket socket)
        {
            m_socket = socket;

            m_buffer = BufferPool.Get();
            m_packet = BufferPool.Get();

            m_locker    = new object();
            m_connected = true;

            m_sendCipher = new MapleCipher(Constants.MajorVersion, Constants.SIV, MapleCipher.TransformDirection.Encrypt);
            m_recvCipher = new MapleCipher(Constants.MajorVersion, Constants.RIV, MapleCipher.TransformDirection.Decrypt);

            BeginRead();
        }