예제 #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);
 }