JLChen
2020-05-28 04bd96cbf5d12a4e4b116d2b05fd0d05ea81ee23
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using System;
using System.Collections.Generic;
using System.Net.NetworkInformation;
using System.Net;
using System.Text;
using Shared.SimpleControl;
 
namespace Shared
{
    public class API
    {
 
        public static long PingServerAddress (string serverAddress)
        {
 
            long mRoundtripTime = 2000;
            try {
                //serverAddress = "www.baidu.com";
                Ping pingSender = new Ping ();
                PingOptions options = new PingOptions ();
 
                // Use the default Ttl value which is 128,
                // but change the fragmentation behavior.
                options.Ttl = 150;
                options.DontFragment = true;
 
                // Create a buffer of 32 bytes of data to be transmitted.
                //string data = "a";
                byte [] buffer = Encoding.ASCII.GetBytes (string.Empty);
              
                PingReply reply = pingSender.Send (serverAddress, 2000, buffer, options);
                if (reply.Status == IPStatus.Success) {
                    Console.WriteLine ("Address: {0}", reply.Address.ToString ());
                    Console.WriteLine ("RoundTrip time: {0}", reply.RoundtripTime);
                    Console.WriteLine ("Time to live: {0}", reply.Options.Ttl);
                    Console.WriteLine ("Don't fragment: {0}", reply.Options.DontFragment);
                    Console.WriteLine ("Buffer size: {0}", reply.Buffer.Length);
                    mRoundtripTime = reply.RoundtripTime;
                }
 
               
            } catch (Exception ex) {
                System.Console.WriteLine ($"Ping catch:{ex.ToString()}");
            }
 
            return mRoundtripTime;
            //Console.ReadKey ();
        }
 
        # region EmqMqtt 部分
        //***************************EmqMqtt 部分********************************
        public static string API_HangZhouHdlCloudApi = "https://global.hdlcontrol.com/HangZhouHdlCloudApi/EmqMqtt/";
       
        /// <summary>
        /// 客户端确定选择Emq服务器(默认没有选择则使用中国Emq服务器)
        /// Connection
        /// </summary>
        public static string ConfirmSelectEmqRegion = API_HangZhouHdlCloudApi + "ConfirmSelectEmqRegion";
 
 
        /// <summary>
        /// 客户端获取关联的所有成员帐号信息
        /// Connection
        /// </summary>
        public static string GetShareMemberInfoPagger = API_HangZhouHdlCloudApi + "GetShareMemberInfoPagger";
 
        /// <summary>
        /// 客户端获取连接云端Mqtt信息
        /// Connection
        /// </summary>
        public static string GetConnMqttInfo = API_HangZhouHdlCloudApi + "GetConnMqttInfo";
 
        /// <summary>
        /// 获取分享者Mqtt远程控制信息
        /// Connection
        /// </summary>
        public static string GetShareMemberConnMqttInfo = API_HangZhouHdlCloudApi + "ShareMemberConnMqttInfo";
 
        /// <summary>
        /// 获取所有区Emq服务器信息列表
        /// Connection
        /// </summary>
        public static string GetAllRegionEmqServerList = API_HangZhouHdlCloudApi + "GetAllRegionEmqServerList";
 
        #endregion
    }
 
    #region RequestObj 部分
 
    /// <summary>
    /// BaseRequestObj
    /// </summary>
    [System.Serializable]
    public class BaseRequestObj
    {
        public string RequestVersion = MainPage.CodeIDString;
 
        public string RequestSource = MainPage.RequestSource;
 
        public string LoginAccessToken;
    }
 
    [System.Serializable]
    public class ConfirmSelectEmqRegionRequestObj: BaseRequestObj
    {
        /// <summary>
        /// EMQ服务器Id
        /// </summary>
        public string EmqServerId;
    }
    
 
 
    #endregion
 
 
 
    #region ResponseData 部分
 
    [Serializable]
    public class EmqServerInfoRes
    {
        public string Id { get; set; }
 
        public string EmqDomainOrIp { get; set; }
 
        public bool IsCurrentSelect { get; set; }
    }
 
    [Serializable]
    public class EmqServerListInfoRes
    {
        public List<EmqServerInfoRes> PageData = new List<EmqServerInfoRes> ();
    }
 
 
 
 
    #endregion
}