public JT808Package Receive() { do { if (_data.Count > 0) { var result = _data.First(); _data.Remove(result); return(result); } var buffer = new byte[1024]; var rlen = _client.SocketStream.Read(buffer, 0, 1024); if (rlen > 0) { var data = buffer.AsSpan().Slice(0, rlen).ToArray(); _jUnpacker.DeCode(data, (b) => { var package = new JT808Serializer().Deserialize <JT808Package>(b.AsSpan()); _data.Add(package); }); } else { return(null); } }while (true); }
private void _client_OnReceive(TCPClient <JUnpacker> arg1, byte[] arg2) { _jUnpacker.DeCode(arg2, (b) => { var package = new JT808Serializer().Deserialize <JT808Package>(b.AsSpan()); OnReceive.Invoke(this, package); }); }
private void ClientSokcet_OnReceive(byte[] data) { _jUnpacker.DeCode(data, (b) => { var package = new JT808Serializer().Deserialize <JT808Package>(b.AsSpan()); OnReceive.Invoke(this, package); }); }