public void Write(MqttBufferWriter propertyWriter) { if (propertyWriter is MqttBufferWriter writer) { WriteBinary(writer._buffer, 0, writer.Length); return; } if (propertyWriter == null) { throw new ArgumentNullException(nameof(propertyWriter)); } throw new InvalidOperationException($"{nameof(propertyWriter)} must be of type {nameof(MqttBufferWriter)}"); }
public static IMqttPacketFormatter GetMqttPacketFormatter(MqttProtocolVersion protocolVersion, MqttBufferWriter bufferWriter) { if (protocolVersion == MqttProtocolVersion.Unknown) { throw new InvalidOperationException("MQTT protocol version is invalid."); } switch (protocolVersion) { case MqttProtocolVersion.V500: { return(new MqttV5PacketFormatter(bufferWriter)); } case MqttProtocolVersion.V310: case MqttProtocolVersion.V311: { return(new MqttV3PacketFormatter(bufferWriter, protocolVersion)); } default: { throw new NotSupportedException(); } } }
public MqttPacketFormatterAdapter(MqttProtocolVersion protocolVersion, MqttBufferWriter bufferWriter) : this(bufferWriter) { UseProtocolVersion(protocolVersion); }
public MqttPacketFormatterAdapter(MqttBufferWriter mqttBufferWriter) { _bufferWriter = mqttBufferWriter ?? throw new ArgumentNullException(nameof(mqttBufferWriter)); }