阿里云物联网 .NET Core 客户端 | CZGL.AliIoTClient:8. 委托事件
2019-06-09 20:59
1311 查看
文档目录:
- 说明
- 1. 连接阿里云物联网
- 2. IoT 客户端
- 3. 订阅Topic与响应Topic
- 4. 设备上报属性
- 4.1 上报位置信息
- 5. 设置设备属性
- 6. 设备事件上报
- 7. 服务调用
- 8. 委托事件
- 9. 自定义委托事件方法
CZGL.AliIoTClient 里设置了 7 个委托事件,在程序的不不同生命周期触发。
1)7个委托事件
/// <summary> /// 服务器属性设置 /// </summary> public PublishPropertyEventHandler PubPropertyEventHandler; /// <summary> /// 服务调用 /// </summary> public PublishServiceEventHandler PubServiceEventHandler; /// <summary> /// 收到其它Topic时触发 /// </summary> public PublishCommonEventHandler PubCommonEventHandler; /// <summary> /// 当 QOS=1或2时,收到订阅触发 /// </summary> public uPLibrary.Networking.M2Mqtt.MqttClient.MqttMsgPublishedEventHandler PubedEventHandler; /// <summary> /// 向服务器发布 Topic 时 /// </summary> public uPLibrary.Networking.M2Mqtt.MqttClient.MqttMsgSubscribedEventHandler SubedEventHandler; /// <summary> /// 向服务器发布 Topic 失败时 /// </summary> public uPLibrary.Networking.M2Mqtt.MqttClient.MqttMsgUnsubscribedEventHandler UnSubedEventHandler; /// <summary> /// 断开连接时 /// </summary> public uPLibrary.Networking.M2Mqtt.MqttClient.ConnectionClosedEventHandler ConnectionClosedEventHandler;
使用方法
public static void TestEvent(object sender, MqttMsgPublishEventArgs e) { { // handle message received string topic = e.Topic; string message = Encoding.ASCII.GetString(e.Message); Console.WriteLine("- - - - - - - - - - "); Console.WriteLine("get topic message,Date: " + DateTime.Now.ToLongTimeString()); Console.WriteLine("topic: " + topic); Console.WriteLine("get messgae :\n" + message); }
client.PubPropertyEventHandler += TestEvent;
这里是旧版本的文档,可以参考一下。
https://www.cnblogs.com/whuanle/p/10786991.html
相关文章推荐
- 阿里云物联网 .NET Core 客户端 | CZGL.AliIoTClient:4. 设备上报属性
- 阿里云物联网 .NET Core 客户端 | CZGL.AliIoTClient:7. 服务调用
- 一张图看懂阿里云新发布的物联网设备上云神器——HiTSDB + IoT套件
- Tech Insight携阿里云Link物联网平台助力实现“IoT全栈开发”
- ASP.NET2.0中的ClientScriptManager 类用法—如何添加客户端事件!
- MQTT协议与阿里云IoT物联网平台
- 数组,元素的偏移量,client获取客户端的宽高,添加滚动条,onscroll滚动事件
- ASP.NET2.0中的ClientScriptManager类用法—如何添加客户端事件
- 一张图看懂阿里云新发布的物联网设备上云神器——HiTSDB + IoT套件
- 亮相2018CES:解读阿里云IoT筹谋全球物联网市场的一盘大棋!
- 使用服务端事件委托机制来防止页面重复提交数据或客户端浏览器使用(F5)刷新提交数据
- 1月12日云栖精选夜读:阿里云新推出 HiTSDB + IoT套件 物联网设备上云步入快车道
- ASP.NET2.0中的ClientScriptManager 类用法—如何添加客户端事件
- 阿里云新推出 HiTSDB + IoT套件 物联网设备上云步入快车道
- 阿里云新推出 HiTSDB + IoT套件 物联网设备上云步入快车道
- 阿里云IoT赵磊:ICA联盟,构建未来物联网生态圈 | 金山软件第三季度营收13.03亿元
- ASP.NET AJAX Client Life-Cycle Events 客户端事件周期
- ASP.NET2.0中的ClientScriptManager 类用法—如何添加客户端事件
- 阿里云IoT物联网平台-日志服务详解
- 阿里云新推出 HiTSDB + IoT套件 物联网设备上云步入快车道