| | |
| | | using HDL_ON.UI; |
| | | using HDL_ON.DAL.Server; |
| | | using HDL_ON; |
| | | using Newtonsoft.Json; |
| | | using System.Collections.Generic; |
| | | |
| | | namespace HDL_ON.DAL.Mqtt |
| | | { |
| | |
| | | public static void InitState() |
| | | { |
| | | IfNeedReadAllDeviceStatus = true; |
| | | Common.ApiUtlis.Ins.hadInternet = true; |
| | | StartCloudMqtt(); |
| | | } |
| | | |
| | |
| | | public static async Task StartCloudMqtt() |
| | | { |
| | | //没有网络的状态下尝试一下连接mqtt ,安卓的网络状态变化监听有异常,修改底层麻烦 |
| | | if (MainPage.InternetStatus == 0 && MainPage.LinkHdlMqttCount > 1) |
| | | if (MainPage.InternetStatus == 0 && MainPage.LinkHdlMqttCount > 1 ) |
| | | { |
| | | return; |
| | | } |
| | | |
| | | |
| | | if (!Common.ApiUtlis.Ins.hadInternet) |
| | | { |
| | | return; |
| | | } |
| | |
| | | await Task.Factory.StartNew((Func<Task>)(async () => { |
| | | try |
| | | { |
| | | try |
| | | { |
| | | //增加3秒云服务器连接检测,连不上服务器的时候不刷新数据 |
| | | var dataList = new List<GlobalRegionListRes>(); |
| | | var requestJson = HttpUtil.GetSignRequestJson(new GetRegionListObj() { regionMark = HttpUtil.RegionMark }); |
| | | var revertObj = HttpUtil.RequestHttpsPost(NewAPI.API_POST_GlobalRegionList, requestJson, HttpUtil.GlobalRequestHttpsHost, "", 3); |
| | | if (revertObj == null || revertObj.Code != StateCode.SUCCESS) |
| | | { |
| | | Common.ApiUtlis.Ins.hadInternet = false; |
| | | return; |
| | | } |
| | | else |
| | | { |
| | | Common.ApiUtlis.Ins.hadInternet = true; |
| | | } |
| | | } |
| | | catch |
| | | { |
| | | } |
| | | |
| | | #region 初始化远程Mqtt |
| | | RemoteMqttIsConnecting = true; |
| | | RemoteMqttClient = new MqttFactory().CreateMqttClient(); |
| | |
| | | /// </summary> |
| | | static void ReceiveNotifySqueezeAsync(string mMes) |
| | | { |
| | | #if DEBUG |
| | | //return; |
| | | #endif |
| | | if (mMes == PushSignStr) return;//是自己的登录推送不处理//或者当前不是远程链接状态 |
| | | //测试账号,不挤下线 |
| | | switch (UserInfo.Current.userMobileInfo) |
| | | { |
| | | case "18316672920": |
| | | case "15626203746": |
| | | case "464027401@qq.com": |
| | | return; |
| | | } |
| | | |
| | |
| | | static void SendPushSignOut() |
| | | { |
| | | byte[] message = Encoding.UTF8.GetBytes(PushSignStr); |
| | | #if DEBUG |
| | | MqttRemoteSend(message, 4); |
| | | #endif |
| | | } |
| | | |
| | | /// <summary> |