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

            this._activeDateTime = TimeUtils.utcTime;

            byte[] data;
            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);
            }

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

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

            if (this._cache.length > 0)
            {
                this.ProcessData(outputHandler);
            }
        }
Example #2
0
        internal void ProcessData(byte[] data, int offset, int size, ProcessDataOutputHandler outputHandler)
        {
            if (!this._active)
            {
                return;
            }

            this._kcpProxy.ProcessData(data, offset, size, (outData, outSize) =>
            {
                Packet packet = NetworkHelper.DecodePacket(outData, 0, outSize);
                packet.OnReceive();
                outputHandler(packet);
            });

            this._activeTime = TimeUtils.utcTime;
        }