JLChen
2020-06-05 f86c8b5dcf5c84386745b009fc4115fa9db3b76d
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
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> ();
    }
 
 
 
    public class FindCityObj
    {
        /// <summary>
        /// 城市ID
        /// </summary>
        public string Cid;
 
        /// <summary>
        /// 
        /// </summary>
        public string Location;
 
        /// <summary>
        /// 城市
        /// </summary>
        public string City;
 
        /// <summary>
        /// 
        /// </summary>
        public string Province;
 
        /// <summary>
        /// 
        /// </summary>
        public string Country;
 
 
        /// <summary>
        /// 
        /// </summary>
        public string TimeZone;
    }
 
    public class GetWeatherObj
    {
 
 
        public string Temperature;
 
        /// <summary>
        /// 
        /// </summary>
        public string Humidity;
 
        /// <summary>
        /// 
        /// </summary>
        public string PM25;
        /// <summary>
        /// 
        /// </summary>
        public string Weather;
 
    }
 
    /// <summary>
    /// 提交极光推送ID
    /// </summary>
    public class AddRegIDObj
    {
        public string RegID;
        public string Alias;
        public string Account;
        /// <summary>
        /// 推送APP标识
        /// 0 HDL ON
        /// 1 ZigBee
        /// 2 Control In
        /// </summary>
        public int UserMode;
 
    }
 
    /// <summary>
    /// 提交刷新网关远程连接密码
    /// </summary>
    public class UpdateRemoteSwitchPasswordObj
    {
        public string Token;
        public string MAC;
        public string Password;
 
    }
 
    /// <summary>
    /// 推送TokenID
    /// </summary>
    public class RegIDObj
    {
        public string RegID;
    }
 
    #endregion
}