public Packet ReadPacket(Stream stream) { int readValue = stream.ReadByte(); if (readValue == -1) { return(null); } byte transferId = (byte)readValue; int?transferLengthNullable = StreamOperation.ReadShort(stream); if (transferLengthNullable == null) { return(null); } int transferLength = (int)transferLengthNullable; short?dataLengthNullable = StreamOperation.ReadShort(stream); if (dataLengthNullable == null) { return(null); } short dataLength = (short)dataLengthNullable; byte[] data = StreamOperation.ReadBytes(stream, dataLength); if (data == null) { return(null); } return(new NewTransferPacket(transferId, transferLength, data)); }
public Packet ReadPacket(Stream stream) { short?dataLengthNullable = StreamOperation.ReadShort(stream); if (dataLengthNullable == null) { return(null); } short dataLength = (short)dataLengthNullable; byte[] data = StreamOperation.ReadBytes(stream, dataLength); if (data == null) { return(null); } return(new SmallDataPacket(data)); }