com.xmobitea.changx.gn-unity 2.0.3 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/GNServerSettingsEditor.cs +16 -300
- package/Runtime/Common/GNArray.cs +387 -302
- package/Runtime/Common/GNArray.cs.meta +11 -11
- package/Runtime/Common/GNData.cs +61 -48
- package/Runtime/Common/GNData.cs.meta +11 -11
- package/Runtime/Common/GNHashtable.cs +404 -241
- package/Runtime/Common/GNHashtable.cs.meta +11 -11
- package/Runtime/Common/IGNData.cs +20 -11
- package/Runtime/Common/IGNData.cs.meta +11 -11
- package/Runtime/Common.meta +8 -8
- package/Runtime/Config/GNServerSettings.cs +136 -92
- package/Runtime/Config/GNServerSettings.cs.meta +11 -11
- package/Runtime/Config.meta +8 -8
- package/Runtime/Constant/Commands.cs +82 -19
- package/Runtime/Constant/Commands.cs.meta +11 -11
- package/Runtime/Constant/EnumType/FriendStatus.cs +12 -12
- package/Runtime/Constant/EnumType/FriendStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/GoogleLoginType.cs +5 -5
- package/Runtime/Constant/EnumType/GoogleLoginType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/GroupStatus.cs +7 -7
- package/Runtime/Constant/EnumType/GroupStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/InvalidMemberType.cs +23 -23
- package/Runtime/Constant/EnumType/InvalidMemberType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/ItemType.cs +5 -5
- package/Runtime/Constant/EnumType/ItemType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/MatchmakingMemberStatus.cs +6 -6
- package/Runtime/Constant/EnumType/MatchmakingMemberStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/MatchmakingTicketStatus.cs +2 -2
- package/Runtime/Constant/EnumType/MatchmakingTicketStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/OwnerType.cs +3 -2
- package/Runtime/Constant/EnumType/OwnerType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/PermissionDataItem.cs +10 -10
- package/Runtime/Constant/EnumType/PermissionDataItem.cs.meta +11 -11
- package/Runtime/Constant/EnumType/PushPlatformType.cs +10 -0
- package/Runtime/Constant/EnumType/PushPlatformType.cs.meta +11 -0
- package/Runtime/Constant/EnumType/RequestRole.cs +11 -11
- package/Runtime/Constant/EnumType/RequestRole.cs.meta +7 -7
- package/Runtime/Constant/EnumType/RequestType.cs +20 -19
- package/Runtime/Constant/EnumType/RequestType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/StoreReceiveType.cs +13 -0
- package/Runtime/Constant/EnumType/StoreReceiveType.cs.meta +11 -0
- package/Runtime/Constant/EnumType.meta +8 -8
- package/Runtime/Constant/ErrorCode/GNErrorCode.cs +53 -48
- package/Runtime/Constant/ErrorCode/GNErrorCode.cs.meta +7 -7
- package/Runtime/Constant/ErrorCode.meta +8 -8
- package/Runtime/Constant/EventCode.cs +43 -16
- package/Runtime/Constant/EventCode.cs.meta +11 -11
- package/Runtime/Constant/OperationCode.cs +249 -211
- package/Runtime/Constant/OperationCode.cs.meta +11 -11
- package/Runtime/Constant/ParameterCode/GNParameterCode.cs +610 -466
- package/Runtime/Constant/ParameterCode/GNParameterCode.cs.meta +11 -11
- package/Runtime/Constant/ParameterCode/ParameterCode.cs +12 -12
- package/Runtime/Constant/ParameterCode/ParameterCode.cs.meta +11 -11
- package/Runtime/Constant/ParameterCode.meta +8 -8
- package/Runtime/Constant/ReturnCode.cs +73 -25
- package/Runtime/Constant/ReturnCode.cs.meta +11 -11
- package/Runtime/Constant.meta +8 -8
- package/Runtime/Entity/DataMember.cs +342 -124
- package/Runtime/Entity/DataMember.cs.meta +11 -11
- package/Runtime/Entity/GNMetadata.cs +72 -27
- package/Runtime/Entity/GNMetadata.cs.meta +11 -11
- package/Runtime/Entity/InvalidMember.cs +52 -33
- package/Runtime/Entity/InvalidMember.cs.meta +11 -11
- package/Runtime/Entity/Models/AuthenticateModels.cs +251 -207
- package/Runtime/Entity/Models/AuthenticateModels.cs.meta +11 -11
- package/Runtime/Entity/Models/AuthenticateRequestModels.cs +153 -131
- package/Runtime/Entity/Models/AuthenticateRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/AuthenticateResponseModels.cs +61 -51
- package/Runtime/Entity/Models/AuthenticateResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CharacterPlayerModels.cs +985 -849
- package/Runtime/Entity/Models/CharacterPlayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CharacterPlayerRequestModels.cs +957 -885
- package/Runtime/Entity/Models/CharacterPlayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CharacterPlayerResponseModels.cs +165 -150
- package/Runtime/Entity/Models/CharacterPlayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CloudScriptModels.cs +185 -0
- package/Runtime/Entity/Models/CloudScriptModels.cs.meta +11 -0
- package/Runtime/Entity/Models/CloudScriptRequestModels.cs +134 -0
- package/Runtime/Entity/Models/CloudScriptRequestModels.cs.meta +11 -0
- package/Runtime/Entity/Models/CloudScriptResponseModels.cs +34 -0
- package/Runtime/Entity/Models/CloudScriptResponseModels.cs.meta +11 -0
- package/Runtime/Entity/Models/ContentModels.cs +150 -153
- package/Runtime/Entity/Models/ContentModels.cs.meta +11 -11
- package/Runtime/Entity/Models/ContentRequestModels.cs +129 -129
- package/Runtime/Entity/Models/ContentRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/ContentResponseModels.cs +24 -24
- package/Runtime/Entity/Models/ContentResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/DashboardModels.cs +1684 -1156
- package/Runtime/Entity/Models/DashboardModels.cs.meta +11 -11
- package/Runtime/Entity/Models/DashboardRequestModels.cs +220 -147
- package/Runtime/Entity/Models/DashboardRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/DashboardResponseModels.cs +92 -57
- package/Runtime/Entity/Models/DashboardResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GamePlayerModels.cs +1073 -933
- package/Runtime/Entity/Models/GamePlayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GamePlayerRequestModels.cs +939 -867
- package/Runtime/Entity/Models/GamePlayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GamePlayerResponseModels.cs +162 -147
- package/Runtime/Entity/Models/GamePlayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GenericModels.cs +102 -102
- package/Runtime/Entity/Models/GenericModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GroupModels.cs +812 -676
- package/Runtime/Entity/Models/GroupModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GroupRequestModels.cs +741 -669
- package/Runtime/Entity/Models/GroupRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GroupResponseModels.cs +129 -114
- package/Runtime/Entity/Models/GroupResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/InventoryModels.cs +667 -558
- package/Runtime/Entity/Models/InventoryModels.cs.meta +11 -11
- package/Runtime/Entity/Models/InventoryRequestModels.cs +626 -579
- package/Runtime/Entity/Models/InventoryRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/InventoryResponseModels.cs +109 -99
- package/Runtime/Entity/Models/InventoryResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MasterPlayerModels.cs +1882 -1340
- package/Runtime/Entity/Models/MasterPlayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MasterPlayerRequestModels.cs +1643 -1253
- package/Runtime/Entity/Models/MasterPlayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MasterPlayerResponseModels.cs +293 -213
- package/Runtime/Entity/Models/MasterPlayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MultiplayerModels.cs +293 -223
- package/Runtime/Entity/Models/MultiplayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MultiplayerRequestModels.cs +199 -149
- package/Runtime/Entity/Models/MultiplayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MultiplayerResponseModels.cs +59 -49
- package/Runtime/Entity/Models/MultiplayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/StoreInventoryModels.cs +514 -323
- package/Runtime/Entity/Models/StoreInventoryModels.cs.meta +11 -11
- package/Runtime/Entity/Models/StoreInventoryRequestModels.cs +236 -165
- package/Runtime/Entity/Models/StoreInventoryRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/StoreInventoryResponseModels.cs +45 -30
- package/Runtime/Entity/Models/StoreInventoryResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models.meta +8 -8
- package/Runtime/Entity/OperationEvent.cs +111 -75
- package/Runtime/Entity/OperationEvent.cs.meta +11 -11
- package/Runtime/Entity/OperationHelper.cs +51 -35
- package/Runtime/Entity/OperationHelper.cs.meta +11 -11
- package/Runtime/Entity/OperationRequest.cs +142 -99
- package/Runtime/Entity/OperationRequest.cs.meta +11 -11
- package/Runtime/Entity/OperationResponse.cs +111 -63
- package/Runtime/Entity/OperationResponse.cs.meta +11 -11
- package/Runtime/Entity/Request/CustomOperationRequest.cs +112 -61
- package/Runtime/Entity/Request/CustomOperationRequest.cs.meta +11 -11
- package/Runtime/Entity/Request.meta +8 -8
- package/Runtime/Entity/Response/CustomOperationResponse.cs +84 -63
- package/Runtime/Entity/Response/CustomOperationResponse.cs.meta +11 -11
- package/Runtime/Entity/Response.meta +8 -8
- package/Runtime/Entity.meta +8 -8
- package/Runtime/GNNetwork.cs +496 -182
- package/Runtime/GNNetwork.cs.meta +11 -11
- package/Runtime/GNNetworkApi.cs +38 -19
- package/Runtime/GNNetworkApi.cs.meta +11 -11
- package/Runtime/GNNetworkAuthenticateApi.cs +531 -98
- package/Runtime/GNNetworkAuthenticateApi.cs.meta +11 -11
- package/Runtime/GNNetworkCharacterPlayerApi.cs +1587 -762
- package/Runtime/GNNetworkCharacterPlayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkCloudScriptApi.cs +181 -0
- package/Runtime/GNNetworkCloudScriptApi.cs.meta +11 -0
- package/Runtime/GNNetworkContentApi.cs +238 -132
- package/Runtime/GNNetworkContentApi.cs.meta +11 -11
- package/Runtime/GNNetworkDashboardApi.cs +278 -117
- package/Runtime/GNNetworkDashboardApi.cs.meta +11 -11
- package/Runtime/GNNetworkGamePlayerApi.cs +1558 -747
- package/Runtime/GNNetworkGamePlayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkGroupApi.cs +1228 -582
- package/Runtime/GNNetworkGroupApi.cs.meta +11 -11
- package/Runtime/GNNetworkInventoryApi.cs +1048 -507
- package/Runtime/GNNetworkInventoryApi.cs.meta +11 -11
- package/Runtime/GNNetworkMasterPlayerApi.cs +2586 -1067
- package/Runtime/GNNetworkMasterPlayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkMultiplayerApi.cs +328 -147
- package/Runtime/GNNetworkMultiplayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkStoreInventoryApi.cs +388 -162
- package/Runtime/GNNetworkStoreInventoryApi.cs.meta +11 -11
- package/Runtime/Helper/CodeHelper.cs +140 -98
- package/Runtime/Helper/CodeHelper.cs.meta +11 -11
- package/Runtime/Helper/ConverterService.cs +236 -52
- package/Runtime/Helper/ConverterService.cs.meta +11 -11
- package/Runtime/Helper/ParseGNHelper.cs +451 -451
- package/Runtime/Helper/ParseGNHelper.cs.meta +11 -11
- package/Runtime/Helper.meta +8 -8
- package/Runtime/Logger/GNDebug.cs +92 -49
- package/Runtime/Logger/GNDebug.cs.meta +11 -11
- package/Runtime/Logger.meta +8 -8
- package/Runtime/Networking/AuthenticateStatus.cs +57 -35
- package/Runtime/Networking/AuthenticateStatus.cs.meta +11 -11
- package/Runtime/Networking/Handler/IServerEventHandler.cs +25 -25
- package/Runtime/Networking/Handler/IServerEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnCharacterPlayerFriendUpdateEventHandler.cs +61 -32
- package/Runtime/Networking/Handler/OnCharacterPlayerFriendUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnCharacterPlayerGroupUpdateEventHandler.cs +54 -33
- package/Runtime/Networking/Handler/OnCharacterPlayerGroupUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGamePlayerFriendUpdateEventHandler.cs +54 -32
- package/Runtime/Networking/Handler/OnGamePlayerFriendUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGamePlayerGroupUpdateEventHandler.cs +54 -32
- package/Runtime/Networking/Handler/OnGamePlayerGroupUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGroupMemberUpdateEventHandler.cs +48 -29
- package/Runtime/Networking/Handler/OnGroupMemberUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGroupMessageUpdateEventHandler.cs +47 -29
- package/Runtime/Networking/Handler/OnGroupMessageUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler.meta +8 -8
- package/Runtime/Networking/Http/HttpPeer.cs +68 -25
- package/Runtime/Networking/Http/HttpPeer.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingHttpPeerBase.cs +65 -25
- package/Runtime/Networking/Http/NetworkingHttpPeerBase.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingPeerHttpClientRequest.cs +513 -486
- package/Runtime/Networking/Http/NetworkingPeerHttpClientRequest.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingPeerHttpRequest.cs +172 -142
- package/Runtime/Networking/Http/NetworkingPeerHttpRequest.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingPeerUnityWebRequest.cs +225 -188
- package/Runtime/Networking/Http/NetworkingPeerUnityWebRequest.cs.meta +11 -11
- package/Runtime/Networking/Http.meta +8 -8
- package/Runtime/Networking/IPeer.cs +41 -19
- package/Runtime/Networking/IPeer.cs.meta +11 -11
- package/Runtime/Networking/NetworkingPeer.cs +198 -144
- package/Runtime/Networking/NetworkingPeer.cs.meta +11 -11
- package/Runtime/Networking/NetworkingPeerAPI.cs +20 -21
- package/Runtime/Networking/NetworkingPeerAPI.cs.meta +11 -11
- package/Runtime/Networking/OperationPending.cs +159 -95
- package/Runtime/Networking/OperationPending.cs.meta +11 -11
- package/Runtime/Networking/PeerBase.cs +305 -242
- package/Runtime/Networking/PeerBase.cs.meta +11 -11
- package/Runtime/Networking/Socket/NetworkingPeerSocketV2.cs +222 -185
- package/Runtime/Networking/Socket/NetworkingPeerSocketV2.cs.meta +11 -11
- package/Runtime/Networking/Socket/NetworkingPeerSocketV3.cs +235 -177
- package/Runtime/Networking/Socket/NetworkingPeerSocketV3.cs.meta +11 -11
- package/Runtime/Networking/Socket/NetworkingSocketPeerBase.cs +165 -23
- package/Runtime/Networking/Socket/NetworkingSocketPeerBase.cs.meta +11 -11
- package/Runtime/Networking/Socket/SocketPeer.cs +242 -197
- package/Runtime/Networking/Socket/SocketPeer.cs.meta +11 -11
- package/Runtime/Networking/Socket.meta +8 -8
- package/Runtime/Networking.meta +8 -8
- package/Runtime/Unity/ServiceCoroutine.cs +10 -0
- package/Runtime/Unity/ServiceCoroutine.cs.meta +11 -0
- package/Runtime/Unity/ServiceUpdate.cs +33 -20
- package/Runtime/Unity/ServiceUpdate.cs.meta +11 -11
- package/Runtime/Unity.meta +8 -8
- package/Runtime/XmobiTea.GN.runtime.asmdef +16 -16
- package/Runtime/XmobiTea.GN.runtime.asmdef.meta +7 -7
- package/package.json +1 -1
|
@@ -1,486 +1,513 @@
|
|
|
1
|
-
namespace XmobiTea.GN.Networking.Http
|
|
2
|
-
{
|
|
3
|
-
using System;
|
|
4
|
-
using System.Net;
|
|
5
|
-
using System.Net.Http;
|
|
6
|
-
using System.Text;
|
|
7
|
-
using XmobiTea.GN.Common;
|
|
8
|
-
using XmobiTea.GN.Constant;
|
|
9
|
-
using XmobiTea.GN.Helper;
|
|
10
|
-
using XmobiTea.MsgPack;
|
|
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
|
-
if (
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
{
|
|
174
|
-
var
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
var httpAppResponse = new HttpAppResponse
|
|
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
|
-
|
|
233
|
-
//
|
|
234
|
-
//
|
|
235
|
-
//
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
//
|
|
241
|
-
|
|
242
|
-
//
|
|
243
|
-
//
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
//
|
|
247
|
-
|
|
248
|
-
//
|
|
249
|
-
|
|
250
|
-
//
|
|
251
|
-
|
|
252
|
-
//
|
|
253
|
-
//
|
|
254
|
-
|
|
255
|
-
//
|
|
256
|
-
|
|
257
|
-
//
|
|
258
|
-
|
|
259
|
-
//
|
|
260
|
-
//
|
|
261
|
-
//
|
|
262
|
-
|
|
263
|
-
//
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
//
|
|
267
|
-
|
|
268
|
-
//
|
|
269
|
-
|
|
270
|
-
//
|
|
271
|
-
|
|
272
|
-
//
|
|
273
|
-
//
|
|
274
|
-
|
|
275
|
-
//
|
|
276
|
-
|
|
277
|
-
//
|
|
278
|
-
//
|
|
279
|
-
//
|
|
280
|
-
//
|
|
281
|
-
//
|
|
282
|
-
|
|
283
|
-
//
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
//
|
|
287
|
-
//
|
|
288
|
-
//
|
|
289
|
-
|
|
290
|
-
//
|
|
291
|
-
|
|
292
|
-
//
|
|
293
|
-
//
|
|
294
|
-
//
|
|
295
|
-
//
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
//
|
|
299
|
-
//
|
|
300
|
-
|
|
301
|
-
//
|
|
302
|
-
|
|
303
|
-
//
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
{
|
|
307
|
-
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
//
|
|
341
|
-
//
|
|
342
|
-
|
|
343
|
-
//
|
|
344
|
-
//
|
|
345
|
-
//
|
|
346
|
-
|
|
347
|
-
//
|
|
348
|
-
//
|
|
349
|
-
//
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
//
|
|
353
|
-
|
|
354
|
-
//
|
|
355
|
-
|
|
356
|
-
//
|
|
357
|
-
|
|
358
|
-
//
|
|
359
|
-
//
|
|
360
|
-
//
|
|
361
|
-
//
|
|
362
|
-
|
|
363
|
-
//
|
|
364
|
-
|
|
365
|
-
//
|
|
366
|
-
|
|
367
|
-
//
|
|
368
|
-
//
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
//
|
|
372
|
-
|
|
373
|
-
//
|
|
374
|
-
//
|
|
375
|
-
//
|
|
376
|
-
//
|
|
377
|
-
|
|
378
|
-
//
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
//
|
|
382
|
-
//
|
|
383
|
-
//
|
|
384
|
-
//
|
|
385
|
-
|
|
386
|
-
//
|
|
387
|
-
//
|
|
388
|
-
|
|
389
|
-
//
|
|
390
|
-
//}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
//
|
|
422
|
-
|
|
423
|
-
//
|
|
424
|
-
//
|
|
425
|
-
|
|
426
|
-
//
|
|
427
|
-
//
|
|
428
|
-
//
|
|
429
|
-
|
|
430
|
-
//
|
|
431
|
-
//
|
|
432
|
-
//
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
//
|
|
436
|
-
|
|
437
|
-
//
|
|
438
|
-
|
|
439
|
-
//
|
|
440
|
-
|
|
441
|
-
//
|
|
442
|
-
//
|
|
443
|
-
//
|
|
444
|
-
//
|
|
445
|
-
|
|
446
|
-
//
|
|
447
|
-
|
|
448
|
-
//
|
|
449
|
-
|
|
450
|
-
//
|
|
451
|
-
//
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
//
|
|
455
|
-
|
|
456
|
-
//
|
|
457
|
-
//
|
|
458
|
-
//
|
|
459
|
-
//
|
|
460
|
-
|
|
461
|
-
//
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
//
|
|
465
|
-
//
|
|
466
|
-
//
|
|
467
|
-
//
|
|
468
|
-
|
|
469
|
-
//
|
|
470
|
-
//
|
|
471
|
-
|
|
472
|
-
//
|
|
473
|
-
//
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
}
|
|
1
|
+
namespace XmobiTea.GN.Networking.Http
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using System.Net;
|
|
5
|
+
using System.Net.Http;
|
|
6
|
+
using System.Text;
|
|
7
|
+
using XmobiTea.GN.Common;
|
|
8
|
+
using XmobiTea.GN.Constant;
|
|
9
|
+
using XmobiTea.GN.Helper;
|
|
10
|
+
using XmobiTea.MsgPack;
|
|
11
|
+
|
|
12
|
+
/// <summary>
|
|
13
|
+
/// Handles HTTP networking using HttpWebRequest or HttpClient.
|
|
14
|
+
/// </summary>
|
|
15
|
+
internal class NetworkingPeerHttpWebRequest : NetworkingHttpPeerBase
|
|
16
|
+
{
|
|
17
|
+
private readonly HttpClient client;
|
|
18
|
+
|
|
19
|
+
/// <summary>
|
|
20
|
+
/// Sends a GET request using HttpWebRequest or HttpClient.
|
|
21
|
+
/// </summary>
|
|
22
|
+
/// <param name="subUri">The sub-URI for the request.</param>
|
|
23
|
+
/// <param name="onHttpAppResponse">Callback to handle the HTTP response.</param>
|
|
24
|
+
/// <param name="timeout">Timeout for the request, in seconds.</param>
|
|
25
|
+
/// <param name="authToken">Optional authentication token.</param>
|
|
26
|
+
/// <param name="secretKey">Optional secret key.</param>
|
|
27
|
+
public override void getRequest(string subUri, Action<HttpAppResponse> onHttpAppResponse, float timeout, string authToken, string secretKey, string gameId)
|
|
28
|
+
{
|
|
29
|
+
this.getRequestViaHttpWeb(subUri, onHttpAppResponse, timeout, authToken, secretKey, gameId);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private async void getRequestViaHttpWeb(string subUri, Action<HttpAppResponse> onHttpAppResponse, float timeout, string authToken, string secretKey, string gameId)
|
|
33
|
+
{
|
|
34
|
+
using (var requestMessage = new HttpRequestMessage(HttpMethod.Get, this.httpUrl + "/" + subUri))
|
|
35
|
+
{
|
|
36
|
+
if (!string.IsNullOrEmpty(authToken)) requestMessage.Headers.Add(Commands.RequestAuthTokenCmd, authToken);
|
|
37
|
+
if (!string.IsNullOrEmpty(secretKey)) requestMessage.Headers.Add(Commands.RequestSecretCmd, secretKey);
|
|
38
|
+
if (!string.IsNullOrEmpty(gameId)) requestMessage.Headers.Add(Commands.RequestGameIdCmd, gameId);
|
|
39
|
+
|
|
40
|
+
try
|
|
41
|
+
{
|
|
42
|
+
var webResponse = await this.client.SendAsync(requestMessage);
|
|
43
|
+
|
|
44
|
+
var httpAppResponse = new HttpAppResponse
|
|
45
|
+
{
|
|
46
|
+
statusCode = (int)webResponse.StatusCode
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
if (webResponse.StatusCode == HttpStatusCode.OK)
|
|
50
|
+
{
|
|
51
|
+
httpAppResponse.data = await webResponse.Content.ReadAsByteArrayAsync();
|
|
52
|
+
httpAppResponse.text = await webResponse.Content.ReadAsStringAsync();
|
|
53
|
+
}
|
|
54
|
+
else
|
|
55
|
+
{
|
|
56
|
+
httpAppResponse.error = webResponse.ReasonPhrase;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
onHttpAppResponse?.Invoke(httpAppResponse);
|
|
60
|
+
}
|
|
61
|
+
catch (Exception e)
|
|
62
|
+
{
|
|
63
|
+
var httpAppResponse = new HttpAppResponse
|
|
64
|
+
{
|
|
65
|
+
statusCode = -1,
|
|
66
|
+
error = e.Message
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
onHttpAppResponse?.Invoke(httpAppResponse);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
//private async void getRequestViaHttpWeb(string subUri, Action<HttpAppResponse> onHttpAppResponse, float timeout, string authToken, string secretKey)
|
|
75
|
+
//{
|
|
76
|
+
// try
|
|
77
|
+
// {
|
|
78
|
+
// var httpRequest = (HttpWebRequest)WebRequest.Create(this.httpUrl + "/" + subUri);
|
|
79
|
+
// httpRequest.UserAgent = this.userAgent;
|
|
80
|
+
// httpRequest.SendChunked = false;
|
|
81
|
+
// // Prevents hitting a proxy if no proxy is available. TODO: Add support for proxy's.
|
|
82
|
+
// httpRequest.Proxy = null;
|
|
83
|
+
|
|
84
|
+
// httpRequest.Method = NetworkingPeerHttpWebRequest.GET;
|
|
85
|
+
// httpRequest.KeepAlive = false;
|
|
86
|
+
// httpRequest.Timeout = (int)timeout;
|
|
87
|
+
// httpRequest.ReadWriteTimeout = (int)timeout;
|
|
88
|
+
|
|
89
|
+
// if (!string.IsNullOrEmpty(authToken)) httpRequest.Headers.Add(Commands.RequestAuthTokenCmd, authToken);
|
|
90
|
+
// if (!string.IsNullOrEmpty(secretKey)) httpRequest.Headers.Add(Commands.RequestSecretCmd, secretKey);
|
|
91
|
+
|
|
92
|
+
// var response = await httpRequest.GetResponseAsync();
|
|
93
|
+
|
|
94
|
+
// var webResponse = (HttpWebResponse)response;
|
|
95
|
+
|
|
96
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
97
|
+
// httpAppResponse.statusCode = (int)webResponse.StatusCode;
|
|
98
|
+
|
|
99
|
+
// if (webResponse.StatusCode == HttpStatusCode.OK)
|
|
100
|
+
// {
|
|
101
|
+
// using (var responseStream = webResponse.GetResponseStream())
|
|
102
|
+
// {
|
|
103
|
+
// using (var memoryStream = new MemoryStream())
|
|
104
|
+
// {
|
|
105
|
+
// responseStream.CopyTo(memoryStream);
|
|
106
|
+
|
|
107
|
+
// httpAppResponse.data = memoryStream.ToArray();
|
|
108
|
+
// }
|
|
109
|
+
|
|
110
|
+
// using (var stream = new StreamReader(responseStream))
|
|
111
|
+
// {
|
|
112
|
+
// httpAppResponse.text = stream.ReadToEnd();
|
|
113
|
+
// }
|
|
114
|
+
// }
|
|
115
|
+
// }
|
|
116
|
+
// else
|
|
117
|
+
// {
|
|
118
|
+
// httpAppResponse.error = webResponse.StatusDescription;
|
|
119
|
+
// }
|
|
120
|
+
|
|
121
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
122
|
+
// }
|
|
123
|
+
// catch (WebException e)
|
|
124
|
+
// {
|
|
125
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
126
|
+
|
|
127
|
+
// httpAppResponse.statusCode = -1;
|
|
128
|
+
|
|
129
|
+
// using (var stream = new StreamReader(e.Response.GetResponseStream()))
|
|
130
|
+
// {
|
|
131
|
+
// httpAppResponse.error = stream.ReadToEnd();
|
|
132
|
+
// }
|
|
133
|
+
|
|
134
|
+
// if (string.IsNullOrEmpty(httpAppResponse.error)) httpAppResponse.error = e.Message;
|
|
135
|
+
|
|
136
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
137
|
+
// }
|
|
138
|
+
// catch (Exception e)
|
|
139
|
+
// {
|
|
140
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
141
|
+
|
|
142
|
+
// httpAppResponse.statusCode = -1;
|
|
143
|
+
// httpAppResponse.error = e.Message;
|
|
144
|
+
|
|
145
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
146
|
+
// }
|
|
147
|
+
//}
|
|
148
|
+
|
|
149
|
+
/// <summary>
|
|
150
|
+
/// Sends a POST request using HttpWebRequest or HttpClient.
|
|
151
|
+
/// </summary>
|
|
152
|
+
/// <param name="subUri">The sub-URI for the request.</param>
|
|
153
|
+
/// <param name="param">The parameters to include in the request.</param>
|
|
154
|
+
/// <param name="postType">The type of POST request (e.g., JSON, MsgPack).</param>
|
|
155
|
+
/// <param name="onHttpAppResponse">Callback to handle the HTTP response.</param>
|
|
156
|
+
/// <param name="timeout">Timeout for the request, in seconds.</param>
|
|
157
|
+
/// <param name="authToken">Optional authentication token.</param>
|
|
158
|
+
/// <param name="secretKey">Optional secret key.</param>
|
|
159
|
+
/// <param name="customTags">Optional custom tags.</param>
|
|
160
|
+
public override void postRequest(string subUri, GNHashtable param, PostType postType, Action<HttpAppResponse> onHttpAppResponse, float timeout, string authToken, string secretKey, GNHashtable customTags, string gameId)
|
|
161
|
+
{
|
|
162
|
+
this.postRequestViaHttpWeb(subUri, param, postType, onHttpAppResponse, timeout, authToken, secretKey, customTags, gameId);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
private async void postRequestViaHttpWeb(string subUri, GNHashtable param, PostType postType, Action<HttpAppResponse> onHttpAppResponse, float timeout, string authToken, string secretKey, GNHashtable customTags, string gameId)
|
|
166
|
+
{
|
|
167
|
+
using (var requestMessage = new HttpRequestMessage(HttpMethod.Post, this.httpUrl + "/" + subUri))
|
|
168
|
+
{
|
|
169
|
+
if (param == null) param = new GNHashtable();
|
|
170
|
+
if (customTags != null) param.add(GNParameterCode.CustomTags, customTags);
|
|
171
|
+
|
|
172
|
+
if (postType == PostType.Json)
|
|
173
|
+
{
|
|
174
|
+
var content = Encoding.UTF8.GetBytes(Serializer.Serialize(param.toData()));
|
|
175
|
+
requestMessage.Content = new ByteArrayContent(content);
|
|
176
|
+
requestMessage.Headers.Add(Commands.CONTENT_TYPE, Commands.APPLICATION_JSON);
|
|
177
|
+
}
|
|
178
|
+
else if (postType == PostType.MsgPack)
|
|
179
|
+
{
|
|
180
|
+
var content = MsgPackSerializer.Serialize(param.toData());
|
|
181
|
+
requestMessage.Content = new ByteArrayContent(content);
|
|
182
|
+
requestMessage.Headers.Add(Commands.CONTENT_TYPE, Commands.APPLICATION_MSGPACK);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (!string.IsNullOrEmpty(authToken)) requestMessage.Headers.Add(Commands.RequestAuthTokenCmd, authToken);
|
|
186
|
+
if (!string.IsNullOrEmpty(secretKey)) requestMessage.Headers.Add(Commands.RequestSecretCmd, secretKey);
|
|
187
|
+
if (!string.IsNullOrEmpty(gameId)) requestMessage.Headers.Add(Commands.RequestGameIdCmd, gameId);
|
|
188
|
+
|
|
189
|
+
try
|
|
190
|
+
{
|
|
191
|
+
var webResponse = await this.client.SendAsync(requestMessage);
|
|
192
|
+
|
|
193
|
+
var httpAppResponse = new HttpAppResponse
|
|
194
|
+
{
|
|
195
|
+
statusCode = (int)webResponse.StatusCode
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
if (webResponse.StatusCode == HttpStatusCode.OK)
|
|
199
|
+
{
|
|
200
|
+
httpAppResponse.data = await webResponse.Content.ReadAsByteArrayAsync();
|
|
201
|
+
httpAppResponse.text = await webResponse.Content.ReadAsStringAsync();
|
|
202
|
+
}
|
|
203
|
+
else
|
|
204
|
+
{
|
|
205
|
+
httpAppResponse.error = webResponse.ReasonPhrase;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
onHttpAppResponse?.Invoke(httpAppResponse);
|
|
209
|
+
}
|
|
210
|
+
catch (Exception e)
|
|
211
|
+
{
|
|
212
|
+
var httpAppResponse = new HttpAppResponse
|
|
213
|
+
{
|
|
214
|
+
statusCode = -1,
|
|
215
|
+
error = e.Message
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
onHttpAppResponse?.Invoke(httpAppResponse);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
//private async void postRequestViaHttpWeb(string subUri, GNHashtable param, PostType postType, Action<HttpAppResponse> onHttpAppResponse, float timeout, string authToken, string secretKey, GNHashtable customTags)
|
|
224
|
+
//{
|
|
225
|
+
// try
|
|
226
|
+
// {
|
|
227
|
+
// var httpRequest = (HttpWebRequest)WebRequest.Create(this.httpUrl + "/" + subUri);
|
|
228
|
+
// httpRequest.UserAgent = this.userAgent;
|
|
229
|
+
// httpRequest.SendChunked = false;
|
|
230
|
+
// // Prevents hitting a proxy if no proxy is available. TODO: Add support for proxy's.
|
|
231
|
+
// httpRequest.Proxy = null;
|
|
232
|
+
|
|
233
|
+
// httpRequest.Method = NetworkingPeerHttpWebRequest.POST;
|
|
234
|
+
// httpRequest.KeepAlive = false;
|
|
235
|
+
// httpRequest.Timeout = (int)timeout;
|
|
236
|
+
// httpRequest.ReadWriteTimeout = (int)timeout;
|
|
237
|
+
|
|
238
|
+
// if (param == null) param = new GNHashtable();
|
|
239
|
+
|
|
240
|
+
// if (customTags != null) param.add(GNParameterCode.CustomTags, customTags);
|
|
241
|
+
|
|
242
|
+
// if (postType == PostType.Json)
|
|
243
|
+
// {
|
|
244
|
+
// httpRequest.Headers.Add(Commands.CONTENT_TYPE, Commands.APPLICATION_JSON);
|
|
245
|
+
|
|
246
|
+
// var content = Encoding.UTF8.GetBytes(Serializer.Serialize(param.toData()));
|
|
247
|
+
|
|
248
|
+
// using (var stream = httpRequest.GetRequestStream())
|
|
249
|
+
// {
|
|
250
|
+
// stream.Write(content, 0, content.Length);
|
|
251
|
+
// }
|
|
252
|
+
// }
|
|
253
|
+
// else if (postType == PostType.MsgPack)
|
|
254
|
+
// {
|
|
255
|
+
// httpRequest.Headers.Add(Commands.CONTENT_TYPE, Commands.APPLICATION_MSGPACK);
|
|
256
|
+
|
|
257
|
+
// var content = MsgPackSerializer.Serialize(param.toData());
|
|
258
|
+
|
|
259
|
+
// using (var stream = httpRequest.GetRequestStream())
|
|
260
|
+
// {
|
|
261
|
+
// stream.Write(content, 0, content.Length);
|
|
262
|
+
// }
|
|
263
|
+
// }
|
|
264
|
+
|
|
265
|
+
// if (!string.IsNullOrEmpty(authToken)) httpRequest.Headers.Add(Commands.RequestAuthTokenCmd, authToken);
|
|
266
|
+
// if (!string.IsNullOrEmpty(secretKey)) httpRequest.Headers.Add(Commands.RequestSecretCmd, secretKey);
|
|
267
|
+
|
|
268
|
+
// var response = await httpRequest.GetResponseAsync();
|
|
269
|
+
|
|
270
|
+
// var webResponse = (HttpWebResponse)response;
|
|
271
|
+
|
|
272
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
273
|
+
// httpAppResponse.statusCode = (int)webResponse.StatusCode;
|
|
274
|
+
|
|
275
|
+
// if (webResponse.StatusCode == HttpStatusCode.OK)
|
|
276
|
+
// {
|
|
277
|
+
// using (var responseStream = webResponse.GetResponseStream())
|
|
278
|
+
// {
|
|
279
|
+
// using (var memoryStream = new MemoryStream())
|
|
280
|
+
// {
|
|
281
|
+
// responseStream.CopyTo(memoryStream);
|
|
282
|
+
|
|
283
|
+
// httpAppResponse.data = memoryStream.ToArray();
|
|
284
|
+
// }
|
|
285
|
+
|
|
286
|
+
// using (var stream = new StreamReader(responseStream))
|
|
287
|
+
// {
|
|
288
|
+
// httpAppResponse.text = stream.ReadToEnd();
|
|
289
|
+
// }
|
|
290
|
+
// }
|
|
291
|
+
// }
|
|
292
|
+
// else
|
|
293
|
+
// {
|
|
294
|
+
// httpAppResponse.error = webResponse.StatusDescription;
|
|
295
|
+
// }
|
|
296
|
+
|
|
297
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
298
|
+
// }
|
|
299
|
+
// catch (WebException e)
|
|
300
|
+
// {
|
|
301
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
302
|
+
|
|
303
|
+
// httpAppResponse.statusCode = -1;
|
|
304
|
+
|
|
305
|
+
// using (var stream = new StreamReader(e.Response.GetResponseStream()))
|
|
306
|
+
// {
|
|
307
|
+
// httpAppResponse.error = stream.ReadToEnd();
|
|
308
|
+
// }
|
|
309
|
+
|
|
310
|
+
// if (string.IsNullOrEmpty(httpAppResponse.error)) httpAppResponse.error = e.Message;
|
|
311
|
+
|
|
312
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
313
|
+
// }
|
|
314
|
+
// catch (Exception e)
|
|
315
|
+
// {
|
|
316
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
317
|
+
|
|
318
|
+
// httpAppResponse.statusCode = -1;
|
|
319
|
+
// httpAppResponse.error = e.Message;
|
|
320
|
+
|
|
321
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
322
|
+
// }
|
|
323
|
+
//}
|
|
324
|
+
/// <summary>
|
|
325
|
+
/// Sends a file upload request using HttpWebRequest or HttpClient.
|
|
326
|
+
/// </summary>
|
|
327
|
+
/// <param name="subUri">The sub-URI for the request.</param>
|
|
328
|
+
/// <param name="content">The file content to upload.</param>
|
|
329
|
+
/// <param name="mimetype">The MIME type of the file.</param>
|
|
330
|
+
/// <param name="onHttpAppResponse">Callback to handle the HTTP response.</param>
|
|
331
|
+
/// <param name="timeout">Timeout for the request, in seconds.</param>
|
|
332
|
+
public override void postRequestUpload(string subUri, byte[] content, string mimetype, Action<HttpAppResponse> onHttpAppResponse, float timeout)
|
|
333
|
+
{
|
|
334
|
+
this.postRequestUploadViaHttpWeb(subUri, content, mimetype, onHttpAppResponse, timeout);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
private async void postRequestUploadViaHttpWeb(string subUri, byte[] content, string mimetype, Action<HttpAppResponse> onHttpAppResponse, float timeout)
|
|
338
|
+
{
|
|
339
|
+
//try
|
|
340
|
+
//{
|
|
341
|
+
// var httpRequest = (HttpWebRequest)WebRequest.Create(this.httpUrl + "/" + subUri);
|
|
342
|
+
// httpRequest.UserAgent = this.userAgent;
|
|
343
|
+
// httpRequest.SendChunked = false;
|
|
344
|
+
// // Prevents hitting a proxy if no proxy is available. TODO: Add support for proxy's.
|
|
345
|
+
// httpRequest.Proxy = null;
|
|
346
|
+
|
|
347
|
+
// httpRequest.Method = NetworkingPeerHttpWebRequest.POST;
|
|
348
|
+
// httpRequest.KeepAlive = false;
|
|
349
|
+
// httpRequest.Timeout = (int)timeout;
|
|
350
|
+
// httpRequest.ReadWriteTimeout = (int)timeout;
|
|
351
|
+
|
|
352
|
+
// var authToken = GNNetwork.getAuthenticateStatus().getAuthToken();
|
|
353
|
+
|
|
354
|
+
// if (!string.IsNullOrEmpty(authToken)) httpRequest.Headers.Add(Commands.RequestAuthTokenCmd, authToken);
|
|
355
|
+
|
|
356
|
+
// var headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n" + "Content-Type: application/octet-stream\r\n\r\n";
|
|
357
|
+
|
|
358
|
+
// using (var stream = httpRequest.GetRequestStream())
|
|
359
|
+
// {
|
|
360
|
+
// stream.Write(content, 0, content.Length);
|
|
361
|
+
// }
|
|
362
|
+
|
|
363
|
+
// var response = await httpRequest.GetResponseAsync();
|
|
364
|
+
|
|
365
|
+
// var webResponse = (HttpWebResponse)response;
|
|
366
|
+
|
|
367
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
368
|
+
// httpAppResponse.statusCode = (int)webResponse.StatusCode;
|
|
369
|
+
|
|
370
|
+
// if (webResponse.StatusCode == HttpStatusCode.OK)
|
|
371
|
+
// {
|
|
372
|
+
// using (var responseStream = webResponse.GetResponseStream())
|
|
373
|
+
// {
|
|
374
|
+
// using (var memoryStream = new MemoryStream())
|
|
375
|
+
// {
|
|
376
|
+
// responseStream.CopyTo(memoryStream);
|
|
377
|
+
|
|
378
|
+
// httpAppResponse.data = memoryStream.ToArray();
|
|
379
|
+
// }
|
|
380
|
+
|
|
381
|
+
// using (var stream = new StreamReader(responseStream))
|
|
382
|
+
// {
|
|
383
|
+
// httpAppResponse.text = stream.ReadToEnd();
|
|
384
|
+
// }
|
|
385
|
+
// }
|
|
386
|
+
// }
|
|
387
|
+
// else
|
|
388
|
+
// {
|
|
389
|
+
// httpAppResponse.error = webResponse.StatusDescription;
|
|
390
|
+
// }
|
|
391
|
+
|
|
392
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
393
|
+
//}
|
|
394
|
+
//catch (WebException e)
|
|
395
|
+
//{
|
|
396
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
397
|
+
|
|
398
|
+
// httpAppResponse.statusCode = -1;
|
|
399
|
+
|
|
400
|
+
// using (var stream = new StreamReader(e.Response.GetResponseStream()))
|
|
401
|
+
// {
|
|
402
|
+
// httpAppResponse.error = stream.ReadToEnd();
|
|
403
|
+
// }
|
|
404
|
+
|
|
405
|
+
// if (string.IsNullOrEmpty(httpAppResponse.error)) httpAppResponse.error = e.Message;
|
|
406
|
+
|
|
407
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
408
|
+
//}
|
|
409
|
+
//catch (Exception e)
|
|
410
|
+
//{
|
|
411
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
412
|
+
|
|
413
|
+
// httpAppResponse.statusCode = -1;
|
|
414
|
+
// httpAppResponse.error = e.Message;
|
|
415
|
+
|
|
416
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
417
|
+
//}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
//private async void postRequestUploadViaHttpWeb(string subUri, byte[] content, string mimetype, Action<HttpAppResponse> onHttpAppResponse, float timeout)
|
|
421
|
+
//{
|
|
422
|
+
// try
|
|
423
|
+
// {
|
|
424
|
+
// var httpRequest = (HttpWebRequest)WebRequest.Create(this.httpUrl + "/" + subUri);
|
|
425
|
+
// httpRequest.UserAgent = this.userAgent;
|
|
426
|
+
// httpRequest.SendChunked = false;
|
|
427
|
+
// // Prevents hitting a proxy if no proxy is available. TODO: Add support for proxy's.
|
|
428
|
+
// httpRequest.Proxy = null;
|
|
429
|
+
|
|
430
|
+
// httpRequest.Method = NetworkingPeerHttpWebRequest.POST;
|
|
431
|
+
// httpRequest.KeepAlive = false;
|
|
432
|
+
// httpRequest.Timeout = (int)timeout;
|
|
433
|
+
// httpRequest.ReadWriteTimeout = (int)timeout;
|
|
434
|
+
|
|
435
|
+
// var authToken = GNNetwork.getAuthenticateStatus().getAuthToken();
|
|
436
|
+
|
|
437
|
+
// if (!string.IsNullOrEmpty(authToken)) httpRequest.Headers.Add(Commands.RequestAuthTokenCmd, authToken);
|
|
438
|
+
|
|
439
|
+
// var headerTemplate = "Content-Disposition: form-data; name=\"{0}\"; filename=\"{1}\"\r\n" + "Content-Type: application/octet-stream\r\n\r\n";
|
|
440
|
+
|
|
441
|
+
// using (var stream = httpRequest.GetRequestStream())
|
|
442
|
+
// {
|
|
443
|
+
// stream.Write(content, 0, content.Length);
|
|
444
|
+
// }
|
|
445
|
+
|
|
446
|
+
// var response = await httpRequest.GetResponseAsync();
|
|
447
|
+
|
|
448
|
+
// var webResponse = (HttpWebResponse)response;
|
|
449
|
+
|
|
450
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
451
|
+
// httpAppResponse.statusCode = (int)webResponse.StatusCode;
|
|
452
|
+
|
|
453
|
+
// if (webResponse.StatusCode == HttpStatusCode.OK)
|
|
454
|
+
// {
|
|
455
|
+
// using (var responseStream = webResponse.GetResponseStream())
|
|
456
|
+
// {
|
|
457
|
+
// using (var memoryStream = new MemoryStream())
|
|
458
|
+
// {
|
|
459
|
+
// responseStream.CopyTo(memoryStream);
|
|
460
|
+
|
|
461
|
+
// httpAppResponse.data = memoryStream.ToArray();
|
|
462
|
+
// }
|
|
463
|
+
|
|
464
|
+
// using (var stream = new StreamReader(responseStream))
|
|
465
|
+
// {
|
|
466
|
+
// httpAppResponse.text = stream.ReadToEnd();
|
|
467
|
+
// }
|
|
468
|
+
// }
|
|
469
|
+
// }
|
|
470
|
+
// else
|
|
471
|
+
// {
|
|
472
|
+
// httpAppResponse.error = webResponse.StatusDescription;
|
|
473
|
+
// }
|
|
474
|
+
|
|
475
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
476
|
+
// }
|
|
477
|
+
// catch (WebException e)
|
|
478
|
+
// {
|
|
479
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
480
|
+
|
|
481
|
+
// httpAppResponse.statusCode = -1;
|
|
482
|
+
|
|
483
|
+
// using (var stream = new StreamReader(e.Response.GetResponseStream()))
|
|
484
|
+
// {
|
|
485
|
+
// httpAppResponse.error = stream.ReadToEnd();
|
|
486
|
+
// }
|
|
487
|
+
|
|
488
|
+
// if (string.IsNullOrEmpty(httpAppResponse.error)) httpAppResponse.error = e.Message;
|
|
489
|
+
|
|
490
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
491
|
+
// }
|
|
492
|
+
// catch (Exception e)
|
|
493
|
+
// {
|
|
494
|
+
// var httpAppResponse = new HttpAppResponse();
|
|
495
|
+
|
|
496
|
+
// httpAppResponse.statusCode = -1;
|
|
497
|
+
// httpAppResponse.error = e.Message;
|
|
498
|
+
|
|
499
|
+
// onHttpAppResponse?.Invoke(httpAppResponse);
|
|
500
|
+
// }
|
|
501
|
+
//}
|
|
502
|
+
|
|
503
|
+
/// <summary>
|
|
504
|
+
/// Initializes a new instance of the <see cref="NetworkingPeerHttpWebRequest"/> class.
|
|
505
|
+
/// </summary>
|
|
506
|
+
public NetworkingPeerHttpWebRequest()
|
|
507
|
+
{
|
|
508
|
+
//HTTPManager.KeepAliveDefaultValue = true;
|
|
509
|
+
|
|
510
|
+
this.client = new HttpClient();
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
}
|