public static RdmPacket ReadPacket(RdmBinaryReader data) { RdmPacket rdmPacket = null; RdmHeader header = new RdmHeader(); header.ReadData(data); rdmPacket = RdmPacket.Create(header); if (rdmPacket != null) { rdmPacket.ReadData(data); return(rdmPacket); } else { rdmPacket = RdmPacket.Create(header, typeof(RdmRawPacket)) as RdmRawPacket; if (rdmPacket != null) { rdmPacket.ReadData(data); return(rdmPacket); } } throw new UnknownRdmPacketException(header); }
public static RdmPacket ReadPacket(RdmCommands command, RdmParameters parameterId, RdmBinaryReader contentData) { RdmPacket rdmPacket = null; RdmHeader header = new RdmHeader(); header.Command = command; header.ParameterId = parameterId; rdmPacket = RdmPacket.Create(header); if (rdmPacket != null) { rdmPacket.ReadData(contentData); return(rdmPacket); } else { rdmPacket = RdmPacket.Create(header, typeof(RdmRawPacket)) as RdmRawPacket; if (rdmPacket != null) { rdmPacket.ReadData(contentData); return(rdmPacket); } } throw new UnknownRdmPacketException(header); }
public static bool TryReadPacket(RdmBinaryReader data, out RdmPacket rdmPacket) { RdmHeader header = new RdmHeader(); header.ReadData(data); rdmPacket = RdmPacket.Create(header); if (rdmPacket != null) { rdmPacket.ReadData(data); return(true); } return(false); }