| | |
| | | { |
| | | static SystemRemote () |
| | | { |
| | | //如果在远程连接的情况下,就会有定时发送心跳包 |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | while (true) { |
| | | System.Threading.Thread.Sleep (10 * 1000); |
| | | if (CommonPage.IsRemote) { |
| | | Control.ControlBytesSend (Command.ReadRemark, 0, 0, new byte [] { }, SendCount.Zero); |
| | | Console.WriteLine ("心跳包"); |
| | | } |
| | | } |
| | | }); |
| | | //后面考虑检测网关是否在线,可以这里修改方法检测 |
| | | ////如果在远程连接的情况下,就会有定时发送心跳包 |
| | | //System.Threading.Tasks.Task.Run (() => { |
| | | // while (true) { |
| | | // System.Threading.Thread.Sleep (10 * 1000); |
| | | // if (CommonPage.IsRemote) { |
| | | // Control.ControlBytesSend (Command.ReadRemark, 0, 0, new byte [] { }, SendCount.Zero); |
| | | // Utlis.WriteLine ("心跳包"); |
| | | // } |
| | | // } |
| | | //}); |
| | | |
| | | ////如果在远程连接的情况下,就会有定时发送心跳包 |
| | | //System.Threading.Tasks.Task.Run (() => { |
| | | // while (true) { |
| | | // System.Threading.Thread.Sleep (10 * 1000); |
| | | // if (CommonPage.IsRemote) { |
| | | // Utlis.WriteLine ("心跳包"); |
| | | // byte [] backBytes = Control.ControlBytesSendHasReturn (Command.ReadRemark, 0, 0, new byte [] { }); |
| | | // if (backBytes != null) { |
| | | // Utlis.WriteLine ("心跳包 收到回复"); |
| | | // } |
| | | |
| | | // } |
| | | // } |
| | | //}); |
| | | } |
| | | /// <summary> |
| | | /// 加密算法 |
| | |
| | | byte [] bytes = null; |
| | | var dateTime = DateTime.Now; |
| | | System.Threading.Tasks.Task.Run (() => { |
| | | bytes = new System.Net.WebClient { Proxy = null }.DownloadData ("http://www.baidu.com"); |
| | | bytes = new System.Net.WebClient { Proxy = null }.DownloadData ("https://smarth-api.havells.com"); |
| | | }); |
| | | while ((DateTime.Now - dateTime).TotalMilliseconds < 8000) { |
| | | System.Threading.Thread.Sleep (100); |
| | |
| | | { |
| | | bool result = false; |
| | | bool notInternet = false; |
| | | string linkMsg = UserConfig.Instance.CurrentRegion.RegionName + " : "; |
| | | string linkMsg = UserConfig.Instance.CurrentRegion.Name + " : "; |
| | | try { |
| | | if (!checeInternet ()) { |
| | | MainPage.AddTip (Language.StringByID (R.MyInternationalizationString.CheckInternet)); |
| | |
| | | } |
| | | } |
| | | } catch (Exception ex) { |
| | | Console.WriteLine (ex.Message); |
| | | Utlis.WriteLine (ex.Message); |
| | | } finally { |
| | | if (!result) { |
| | | Application.RunOnMainThread (() => { |