public VBANPacket <T> .Decoded readPacket() { byte[] bytes = new byte[VBANPacket <T> .MaxSize]; int nRead = Read(bytes, 0, bytes.Length); return(VBANPacket <T> .Decode(bytes)); }
public T readData() { VBANPacket <T> .Decoded packet = readPacket(); VBAN.AnyProtocol rcvProt; if (!(rcvProt = packet.Head.Protocol).Equals(ExpectedProtocol)) { throw new InvalidOperationException("Expected Protocol mismatches received protocol " + $"[exp={ExpectedProtocol};rcv={rcvProt}]"); } return(ExpectedProtocol.CreateDataObject(packet.Bytes)); }
public override void Flush() { if (Closed) { throw new InvalidOperationException("Stream is closed"); } if (Buf.Length > VBANPacket <T> .MaxSize) { throw new InvalidOperationException($"Buffer is too large, must be smaller than {VBANPacket<T>.MaxSize}"); } VBANPacket <T> packet = PacketFactory.Create(); packet.Data = Buf.Bytes; byte[] x; _client.Send(x = packet.Bytes, x.Length, IpEndPoint); Buf = new UnfinishedByteArray(VBANPacket <T> .MaxSize, true); }