2.1.3.Install M2Mqtt by Nuget, Example code
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading; using System.Threading.Tasks; using uPLibrary.Networking.M2Mqtt; using uPLibrary.Networking.M2Mqtt.Messages; namespace MQTTPublisher { class Program { static void Main(string[] args) { var id = args[0]; var topic = args[1]; MqttClient client = new MqttClient("127.0.0.1"); //若有輸入user, password, 接收端也要一樣的user, password client.Connect(id); //若要知道有沒有發送出去可以增加監聽發送後的Event client.MqttMsgPublished += new MqttClient.MqttMsgPublishedEventHandler(client_MqttMsgPublished);



Last updated