/// <summary> /// The inputManager, this class manages the connection to the broker. /// </summary> /// <param name="_sAddress"></param> public InputManager(string _sAddress) { // initialize the parser. parser = new DataParser(); databaseManager = new DatabaseManagment.DbManager(); try { IPHostEntry hostEntry = Dns.GetHostEntry(_sAddress); Console.WriteLine(hostEntry); string hostname = hostEntry.HostName; Client = new MqttClient(hostname, 8883, false, null, null, MqttSslProtocols.None); } catch (Exception e) { Program.Log(e.Message); Client = new MqttClient(IPAddress.Parse(_sAddress), 8883, false, null, null, MqttSslProtocols.None); } // setup of the client. Client.ConnectionClosed += Client_ConnectionClosed; Client.MqttMsgSubscribed += Client_MqttMsgSubscribed; Client.MqttMsgPublishReceived += MessageReceived; Client.ProtocolVersion = MqttProtocolVersion.Version_3_1_1; byte response = Client.Connect(Guid.NewGuid().ToString()); // check if the connection is made else print the problem and return. if (Client.IsConnected) { Connected = true; Console.WriteLine("The connection is made " + response); } else { Program.Log("The connection is not made, the return code is : " + response); return; } Client.Subscribe(subjects, qosLevels); }
/// <summary> /// The inputManager, this class manages the connection to the broker. /// </summary> /// <param name="_sAddress"></param> public InputManager(string _sAddress) { // initialize the parser. parser = new DataParser(); databaseManager = new DatabaseManagment.DbManager(); try { IPHostEntry hostEntry = Dns.GetHostEntry(_sAddress); Console.WriteLine(hostEntry); string hostname = hostEntry.HostName; Client = new MqttClient(hostname, 8883); } catch (Exception e) { Program.Log(e.Message); Client = new MqttClient(IPAddress.Parse(_sAddress), 8883, false, null, null, MqttSslProtocols.None); } // setup of the client. Client.ConnectionClosed += Client_ConnectionClosed; Client.MqttMsgSubscribed += Client_MqttMsgSubscribed; Client.MqttMsgPublishReceived += MessageReceived; Client.ProtocolVersion = MqttProtocolVersion.Version_3_1_1; byte response = Client.Connect(Guid.NewGuid().ToString()); // check if the connection is made else print the problem and return. if (Client.IsConnected) { Connected = true; Console.WriteLine("The connection is made " + response); } else { Program.Log("The connection is not made, the return code is : " + response); return; } Client.Subscribe(subjects, qosLevels); }
/// <summary> /// The dataparser responsible for the parsing of the incoming messages of the mqtt broker. /// </summary> public DataParser() { m_cInstance = this; buffer = new Queue <Topic>(); }
/// <summary> /// The dataparser responsible for the parsing of the incoming messages of the mqtt broker. /// </summary> public DataParser() { m_cInstance = this; buffer = new Queue<Topic>(); }