private static void OnMqttMsgUnsubscribeReceived(MqttClientConnection clientConnection, ushort messageId, string[] topics) { for (int i = 0; i < topics.Length; i++) { // unsubscribe client for each topic requested MqttSubscriberManager.Unsubscribe(topics[i], clientConnection); } // send UNSUBACK message to the client MqttOutgoingMessageManager.Unsuback(clientConnection, messageId); }
public MqttManager() { // create managers (publisher, subscriber, session and UAC) this.subscriberManager = new MqttSubscriberManager(); this.sessionManager = new MqttSessionManager(); this.publisherManager = new MqttPublisherManager(this.subscriberManager, this.sessionManager); this.uacManager = new MqttUacManager(); this.clients = new MqttClientCollection(); mqttBridge = Composable.GetExport<IMqttBridge>(); }
public MqttManager() { // create managers (publisher, subscriber, session and UAC) this.subscriberManager = new MqttSubscriberManager(); this.sessionManager = new MqttSessionManager(); this.publisherManager = new MqttPublisherManager(this.subscriberManager, this.sessionManager); this.uacManager = new MqttUacManager(); this.clients = new MqttClientCollection(); mqttBridge = Composable.GetExport <IMqttBridge>(); }
/// <summary> /// Constructor /// </summary> /// <param name="commLayer">Communication layer to use (TCP)</param> /// <param name="settings">Broker settings</param> public MqttBroker(IMqttCommunicationLayer commLayer, MqttSettings settings) { // MQTT broker settings this.settings = settings; // MQTT communication layer this.commLayer = commLayer; this.commLayer.ClientConnected += commLayer_ClientConnected; // create managers (publisher, subscriber, session and UAC) this.subscriberManager = new MqttSubscriberManager(); this.sessionManager = new MqttSessionManager(); this.publisherManager = new MqttPublisherManager(this.subscriberManager, this.sessionManager); this.uacManager = new MqttUacManager(); this.clients = new MqttClientCollection(); }
/// <summary> /// Constructor /// </summary> /// <param name="subscriberManager">Reference to subscriber manager</param> /// <param name="sessionManager">Reference to session manager</param> public MqttPublisherManager(MqttSubscriberManager subscriberManager, MqttSessionManager sessionManager) { // save reference to subscriber manager this.subscriberManager = subscriberManager; // save reference to session manager this.sessionManager = sessionManager; // create empty list for retained messages this.retainedMessages = new Dictionary<string, MqttMsgPublish>(); // create empty list for destination subscribers for retained message this.subscribersForRetained = new Queue<MqttSubscription>(); // create empty list for destination client for outgoing session message this.clientsForSession = new Queue<string>(); // create publish messages queue this.publishQueue = new Queue<MqttMsgBase>(); this.publishQueueWaitHandle = new AutoResetEvent(false); }