/// <summary> /// Initialises an instance of the <see cref="MqttMessagePublisher"/> class. /// </summary> /// <param name="connection"> /// The AMQP connection to use. /// </param> /// <param name="topicName"> /// The topic name to publish to. /// </param> /// <param name="name"> /// The unique name to associate with the link used to send messages on. /// </param> /// <param name="handler"> ///Processes incoming messages from the MQTT broker. /// </param> public MqttMessageSubscriber(MqttConnection connection, string topicName, string name, IMessageHandler handler) { connection.ShouldNotBeNull(); topicName.ShouldNotBeEmpty(); name.ShouldNotBeEmpty(); m_ConnectionId = string.Empty; m_Connection = connection; m_TopicName = topicName; m_Name = name; m_MessageHandler = handler; }
/// <summary> /// Initialises an instance of the <see cref="MqttMessagePublisher"/> class. /// </summary> /// <param name="connection"> /// The AMQP connection to use. /// </param> /// <param name="topicName"> /// The topic name to publish to. /// </param> /// <param name="name"> /// The unique name to associate with the link used to send messages on. /// </param> /// <param name="isDurable"> /// Indicates whether the messages should be durable (Persistent). /// </param> public MqttMessagePublisher(MqttConnection connection, string topicName, string name, bool isDurable = true) { connection.ShouldNotBeNull(); topicName.ShouldNotBeEmpty(); name.ShouldNotBeEmpty(); m_ConnectionId = string.Empty; m_Connection = connection; m_TopicName = topicName; m_Name = name; m_IsDurable = isDurable; }
/// <summary> /// Builds an AMQP publisher. /// </summary> /// <param name="topicName"> /// The name of the AMQP topic to publish /// </param> /// <param name="linkName"> /// The unique name to associate with the link used to send messages on. /// </param> /// <returns> /// An initialised instance of a <see cref="AmqpMessagePublisher"/> class. /// </returns> public IMessagePublisher BuildPublisher(string topicName, string linkName) { var connection = new MqttConnection(m_EndpointAddress); var publisher = new MqttMessagePublisher(connection, topicName, linkName); return publisher; }
/// <summary> /// Builds an AMQP subscriber. /// </summary> /// <param name="topicName"> /// The name of the AMQP topic to subscribe to. /// </param> /// <param name="linkName"> /// The unique name to associate with the link used to receive messages on. /// </param> /// <param name="messageHandler"> /// Processes any incoming message payloads. /// </param> /// <returns> /// An initialised instance of a <see cref="AmqpMessageSubscriber"/> class. /// </returns> public IMessageSubscriber BuildSubscriber(string topicName, string linkName, IMessageHandler messageHandler, int windowSize) { var connection = new MqttConnection(m_EndpointAddress); var subscriber = new MqttMessageSubscriber(connection, topicName, linkName, messageHandler); return subscriber; }