| | |
| | | Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/thing/event/appDeviceRefresh/up", |
| | | QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce |
| | | }; |
| | | //设备在线离线状态推送 |
| | | var deviceOnlinePush = new MqttTopicFilter() |
| | | { |
| | | Topic = $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/son/session/online", |
| | | QualityOfServiceLevel = MQTTnet.Protocol.MqttQualityOfServiceLevel.AtMostOnce |
| | | }; |
| | | //appRoomRefresh:房间数据刷新通知 |
| | | var appRoomRefresh = new MqttTopicFilter() |
| | | { |
| | |
| | | pirStatus,pirStudy, |
| | | appDeviceRefresh,appHomeRefresh,appRoomRefresh,residenceChange, |
| | | topicFilterPush2, topicAlinkStatus ,mqttkeyChange, |
| | | deviceOnlinePush, |
| | | securityStatusChange}); |
| | | if (result.Items[0].ResultCode == MQTTnet.Client.Subscribing.MqttClientSubscribeResultCode.GrantedQoS0) |
| | | { |
| | |
| | | var mMes = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); |
| | | //新挤下线主题方案 收到挤下线主题 |
| | | ReceiveNotifySqueezeAsync(mMes); |
| | | } |
| | | //设备在线离线状态推送 |
| | | else if(topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/son/session/online") |
| | | { |
| | | try |
| | | { |
| | | //var mMes = Encoding.UTF8.GetString(e.ApplicationMessage.Payload); |
| | | //Newtonsoft.Json.Linq.JObject pairs = Newtonsoft.Json.Linq.JObject.Parse(mMes); |
| | | //var pairSid = pairs.GetValue("sid").ToString(); |
| | | //var pairOnline = pairs.GetValue("online"); |
| | | //if (!string.IsNullOrEmpty(pairSid.ToString())) |
| | | //{ |
| | | // var function_online = FunctionList.List.Functions.Find((obj) => obj.sid == pairSid); |
| | | // if (function_online != null){ |
| | | // function_online.online = (bool)pairOnline; |
| | | // HomePage.LoadEvent_RefreshDevcieOnline(function_online); |
| | | // FunctionPage.UpdataOnline(function_online); |
| | | // RoomPage.UpdataOnline(function_online); |
| | | // } |
| | | //} |
| | | |
| | | } |
| | | catch(Exception ex) |
| | | { |
| | | |
| | | } |
| | | } |
| | | //App订阅红外宝/网关遥控器添加成功通知 |
| | | else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/thing/topo/found") |
| | |
| | | } |
| | | #endregion |
| | | //A网关设备状态-包含涂鸦设备 |
| | | //Tag 网络状态解析 |
| | | else if (topic == $"/user/{DB_ResidenceData.Instance.CurrentRegion.id}/app/thing/property/send") |
| | | { |
| | | var bytes = Securitys.EncryptionService.AesDecryptPayload(e.ApplicationMessage.Payload, tuyaEncryptKey); |
| | | var revString = Encoding.UTF8.GetString(bytes); |
| | | MainPage.Log($"mqtt 状态更新:{revString}"); |
| | | Control.Ins.UpdataFunctionStatus(revString, null, true); |
| | | //Control.Ins.MsgInfoList.Add($"mqtt 状态更新:{revString}"); |
| | | |
| | | //Control.Ins.MsgInfoList.Add(revString + "\r\n"); |
| | | } |
| | | //一端口数据解析 |
| | |
| | | /// </summary> |
| | | static void ReceiveNotifySqueezeAsync(string mMes) |
| | | { |
| | | #if DEBUG |
| | | return; |
| | | #endif |
| | | if (mMes == PushSignStr) return;//是自己的登录推送不处理//或者当前不是远程链接状态 |
| | | //测试账号,不挤下线 |
| | | switch (UserInfo.Current.userMobileInfo) |
| | |
| | | static void SendPushSignOut() |
| | | { |
| | | byte[] message = Encoding.UTF8.GetBytes(PushSignStr); |
| | | #if DEBUG |
| | | MqttRemoteSend(message, 4); |
| | | #endif |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | //创建AES解密器对象 |
| | | var cTransform = rm.CreateDecryptor(); |
| | | |
| | | byte[] reData = null; |
| | | //使用AES将密文流转成明文的字节数组 |
| | | return cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); |
| | | try |
| | | { |
| | | reData = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | Console.WriteLine(ex.Message); |
| | | } |
| | | return reData; |
| | | } |
| | | #endregion |
| | | |