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); } }
public void RemoveListener(byte module, ushort cmd, PacketHandler handler) { this._listener.Remove(NetworkHelper.EncodePacketID(module, cmd), handler); }
public PacketAttribute(byte module, ushort command) { this.id = NetworkHelper.EncodePacketID(module, command); }
public void Send(Packet packet) { packet.OnSend(); this.Send(NetworkHelper.EncodePacket(packet)); }
public void Send(Packet packet, RPCHandler callback = null) { this._rpcManager.Accept(packet, callback); packet.OnSend(); this.Send(NetworkHelper.EncodePacket(packet)); }
internal static Type GetPacketType(byte module, ushort command) { return(!PACKET_MAP.TryGetValue(NetworkHelper.EncodePacketID(module, command), out Type type) ? null : type); }