コード例 #1
0
 /// <summary>This ctor only parses and deserializes the OpCode internally.</summary>
 public RawEQPacket(IPEndPoint clientIPE, byte[] data)
     : base(clientIPE, data)
 {
     _rawOpCode = (ushort)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(data, 0));
     if (_rawOpCode < 0x00ff)
         _OpCode = (ProtocolOpCode)_rawOpCode;
 }
コード例 #2
0
        /// <summary>This ctor serializes to the internal buffer with the given opCode and data</summary>
        public RawEQPacket(ProtocolOpCode opCode, byte[] data, IPEndPoint clientIPE)
        {
            _OpCode = opCode;
            _rawOpCode = (ushort)opCode;
            _clientIPE = clientIPE;

            // serialize to buffer
            int dataSize = data.Length + 2;   // opcode
            _data = new byte[dataSize];
            Buffer.BlockCopy(data, 0, _data, 2, data.Length);
            ushort opCodeNO = (ushort)IPAddress.HostToNetworkOrder((short)_OpCode);
            Buffer.BlockCopy(BitConverter.GetBytes(opCodeNO), 0, _data, 0, 2);
        }
コード例 #3
0
        /// <summary>This ctor upscales a BasePacket.  Internally parses OpCode.</summary>
        public RawEQPacket(BasePacket packet, bool hasCrc)
        {
            _rawOpCode = (ushort)IPAddress.NetworkToHostOrder((short)BitConverter.ToUInt16(packet.RawPacketData, 0));
            if (_rawOpCode < 0x00ff)
                _OpCode = (ProtocolOpCode)_rawOpCode;

            _clientIPE = packet.ClientIPE;

            if (hasCrc)
            {
                _data = new byte[packet.RawPacketData.Length - 2];
                Buffer.BlockCopy(packet.RawPacketData, 0, _data, 0, packet.RawPacketData.Length - 2);
            }
            else
            {
                _data = new byte[packet.RawPacketData.Length];
                Buffer.BlockCopy(packet.RawPacketData, 0, _data, 0, packet.RawPacketData.Length);
            }
        }
コード例 #4
0
ファイル: Client.cs プロジェクト: natedahl32/EqEmulator-net
        public void SendSequencedPacket(BasePacket appPacket, ProtocolOpCode opCode)
        {
            // Wrap in a raw packet and throw on sequenced queue
            ushort nextOutSeq_no = (ushort)IPAddress.HostToNetworkOrder((short)_nextOutSeq);
            RawEQPacket packet = new RawEQPacket(opCode, nextOutSeq_no, appPacket.RawPacketData, appPacket.ClientIPE);
            _nextOutSeq++;

            lock (((ICollection)_seqQueue).SyncRoot)
                _seqQueue.Enqueue(packet);
        }