示例#1
0
        internal void ProcessData(ProcessDataOutputHandler outputHandler)
        {
            lock (this._cache)
            {
                if (this._cache.length == 0)
                {
                    return;
                }
            }

            this._activeDateTime = TimeUtils.utcTime;

            byte[] data;
            long   cacheLength;

            lock (this._cache)
            {
                int len = LengthEncoder.Decode(this._cache.GetBuffer(), 0, this._cache.position, out data);
                if (data == null)
                {
                    return;
                }
                this._cache.Strip(len, ( int )this._cache.length - len);
                cacheLength = this._cache.length;
            }

            Packet packet = NetworkHelper.DecodePacket(data, 0, data.Length);

            packet.OnReceive();
            outputHandler.Invoke(packet);

            if (cacheLength > 0)
            {
                this.ProcessData(outputHandler);
            }
        }
示例#2
0
 public void RemoveListener(byte module, ushort cmd, PacketHandler handler)
 {
     this._listener.Remove(NetworkHelper.EncodePacketID(module, cmd), handler);
 }
示例#3
0
 public PacketAttribute(byte module, ushort command)
 {
     this.id = NetworkHelper.EncodePacketID(module, command);
 }
示例#4
0
 public void Send(Packet packet)
 {
     packet.OnSend();
     this.Send(NetworkHelper.EncodePacket(packet));
 }
示例#5
0
 public void Send(Packet packet, RPCHandler callback = null)
 {
     this._rpcManager.Accept(packet, callback);
     packet.OnSend();
     this.Send(NetworkHelper.EncodePacket(packet));
 }
示例#6
0
 internal static Type GetPacketType(byte module, ushort command)
 {
     return(!PACKET_MAP.TryGetValue(NetworkHelper.EncodePacketID(module, command), out Type type) ? null : type);
 }