You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading;
using uPLibrary.Networking.M2Mqtt.Messages;
using uPLibrary.Networking.M2Mqtt.Utility;
namespace uPLibrary.Networking.M2Mqtt
{
class Program
{
static void Main(string[] args)
{
//Trace.TraceLevel = TraceLevel.Verbose | TraceLevel.Frame;
//Trace.TraceListener = (f , a) => Console.WriteLine(f , a);
//// create client instance
//MqttClient client = new MqttClient("127.0.0.1");
//// register to message received
//client.MqttMsgPublishReceived += client_MqttMsgPublishReceived;
//string clientId = "373001_000045_00004";
//client.Connect(clientId,null,null,false,20);
//// subscribe to the topic "/home/temperature" with QoS 2
//client.Subscribe(new string[] { "mqtt/dotnet/azkoss" } , new byte[] { MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE });
//for (int i = 0; i < 100000; i++)
//{
// Thread.Sleep(1000);
// string strValue = Convert.ToString(i);
// // publish a message on "/home/temperature" topic with QoS 2
// client.Publish("mqtt/dotnet/azkoss", Encoding.UTF8.GetBytes(strValue), MqttMsgBase.QOS_LEVEL_EXACTLY_ONCE, false);
//}
}
static void client_MqttMsgPublishReceived(object sender , MqttMsgPublishEventArgs e)
{
Console.WriteLine(Encoding.UTF8.GetString(e.Message));
}
}
}