Example #1
0
        internal void SendPacket(byte[] packet)
        {
            if (Disposed)
            {
                return;
            }

            //TODO: Phase this lock out one day :^)
            lock (m_sendSync)
            {
                if (Disposed)
                {
                    return;
                }

                byte[] final = new byte[packet.Length + 4];

                MapleAes.GetHeader(final, m_siv, m_version);

                Shanda.EncryptTransform(packet);
                MapleAes.Transform(packet, m_siv);

                Buffer.BlockCopy(packet, 0, final, 4, packet.Length);

                SendRaw(final);
            }
        }
Example #2
0
        public override void SendPacket(COutPacket outPacket)
        {
            if (Disposed)
            {
                return;
            }

            lock (m_sendSync)    //TODO: Phase this lock out one day :^)
            {
                if (Disposed)
                {
                    return;
                }

                var packetLen = outPacket.Length;
                var packet    = outPacket.ToArray(); //TODO: phase out this allocation

                var finalLen = packet.Length + 4;
                var final    = BufferPool.Rent(finalLen);

                MapleAes.GetHeader(ref final, ref m_siv, packetLen, m_version);
                Buffer.BlockCopy(packet, 0, final, 4, packetLen);

                var span = new Span <byte>(final, 4, packetLen);
                Shanda.EncryptTransform(ref span);
                MapleAes.Transform(ref span, ref m_siv);

                SendAsync(final, 0, finalLen, final);
            }
        }