com.xmobitea.changx.gn-unity 2.0.3 → 2.4.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 +614 -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 +501 -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,242 +1,305 @@
|
|
|
1
|
-
namespace XmobiTea.GN.Networking
|
|
2
|
-
{
|
|
3
|
-
using System;
|
|
4
|
-
using System.Collections.Generic;
|
|
5
|
-
using System.Linq;
|
|
6
|
-
using
|
|
7
|
-
using XmobiTea.GN.
|
|
8
|
-
using XmobiTea.GN.
|
|
9
|
-
using XmobiTea.GN.
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
private
|
|
19
|
-
|
|
20
|
-
private
|
|
21
|
-
|
|
22
|
-
private float
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
void
|
|
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
|
-
this.
|
|
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
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
1
|
+
namespace XmobiTea.GN.Networking
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.Linq;
|
|
6
|
+
using XmobiTea.GN.Common;
|
|
7
|
+
using XmobiTea.GN.Constant;
|
|
8
|
+
using XmobiTea.GN.Entity;
|
|
9
|
+
using XmobiTea.GN.Logger;
|
|
10
|
+
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// Abstract base class for managing common functionalities of network peers.
|
|
13
|
+
/// Implements the <see cref="IPeer"/> interface.
|
|
14
|
+
/// </summary>
|
|
15
|
+
internal abstract class PeerBase : IPeer
|
|
16
|
+
{
|
|
17
|
+
private Queue<OperationPending> operationPendingQueue; // Queue to store pending operations to be sent.
|
|
18
|
+
private Dictionary<int, OperationPending> operationWaitingResponseDict; // Dictionary to track operations awaiting responses.
|
|
19
|
+
|
|
20
|
+
private static int requestId; // Static counter for generating unique request IDs.
|
|
21
|
+
|
|
22
|
+
private float perMsgTimer; // Interval between sending messages.
|
|
23
|
+
private float nextSendMsgTimer; // Time for the next message to be sent.
|
|
24
|
+
private float checkTimeoutOperationPending = 0; // Timer to check for timed-out operations.
|
|
25
|
+
|
|
26
|
+
/// <summary>
|
|
27
|
+
/// Gets the message send rate (messages per second).
|
|
28
|
+
/// </summary>
|
|
29
|
+
/// <returns>The send rate in messages per second.</returns>
|
|
30
|
+
protected int getSendRate()
|
|
31
|
+
{
|
|
32
|
+
return (int)(1000 / this.perMsgTimer);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/// <summary>
|
|
36
|
+
/// Sets the message send rate (messages per second).
|
|
37
|
+
/// </summary>
|
|
38
|
+
/// <param name="sendRate">The desired send rate in messages per second.</param>
|
|
39
|
+
protected void setSendRate(int sendRate)
|
|
40
|
+
{
|
|
41
|
+
this.perMsgTimer = (float)1000 / sendRate / 1000;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/// <summary>
|
|
45
|
+
/// Gets or sets the ping value for the connection.
|
|
46
|
+
/// </summary>
|
|
47
|
+
internal int ping { get; set; } = -1;
|
|
48
|
+
|
|
49
|
+
private Queue<float> pingLst; // Queue to store recent ping values for averaging.
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
/// Gets or sets whether this peer is in use.
|
|
53
|
+
/// </summary>
|
|
54
|
+
protected bool isUse { get; set; }
|
|
55
|
+
|
|
56
|
+
/// <summary>
|
|
57
|
+
/// Initializes the peer by setting up queues, dictionaries, and network objects.
|
|
58
|
+
/// </summary>
|
|
59
|
+
void IPeer.initPeer()
|
|
60
|
+
{
|
|
61
|
+
if (this.operationWaitingResponseDict == null)
|
|
62
|
+
this.operationWaitingResponseDict = new Dictionary<int, OperationPending>();
|
|
63
|
+
|
|
64
|
+
if (this.operationPendingQueue == null)
|
|
65
|
+
this.operationPendingQueue = new Queue<OperationPending>();
|
|
66
|
+
|
|
67
|
+
if (this.pingLst == null)
|
|
68
|
+
this.pingLst = new Queue<float>();
|
|
69
|
+
|
|
70
|
+
this.initSendRate();
|
|
71
|
+
this.initGNSocketObject();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// <summary>
|
|
75
|
+
/// Initializes the message send rate based on the server settings.
|
|
76
|
+
/// </summary>
|
|
77
|
+
/// <exception cref="NullReferenceException">Thrown if server settings are not available.</exception>
|
|
78
|
+
private void initSendRate()
|
|
79
|
+
{
|
|
80
|
+
var gnServerSettings = GNNetwork.gnServerSettings;
|
|
81
|
+
if (gnServerSettings == null)
|
|
82
|
+
throw new NullReferenceException("Null GN Server Settings, please find it now");
|
|
83
|
+
|
|
84
|
+
this.setSendRate(gnServerSettings.getSendRate());
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/// <summary>
|
|
88
|
+
/// Initializes the GN socket object for derived classes.
|
|
89
|
+
/// This method must be implemented in subclasses.
|
|
90
|
+
/// </summary>
|
|
91
|
+
internal abstract void initGNSocketObject();
|
|
92
|
+
|
|
93
|
+
/// <summary>
|
|
94
|
+
/// Enqueues an operation request for processing.
|
|
95
|
+
/// </summary>
|
|
96
|
+
/// <param name="requestType">The type of the request.</param>
|
|
97
|
+
/// <param name="requestRole">The role associated with the request.</param>
|
|
98
|
+
/// <param name="operationRequest">The operation request to be enqueued.</param>
|
|
99
|
+
/// <param name="onOperationResponse">The callback for the response.</param>
|
|
100
|
+
/// <param name="authToken">The authentication token.</param>
|
|
101
|
+
/// <param name="secretKey">The secret key, if applicable.</param>
|
|
102
|
+
/// <param name="customTags">Custom tags for the operation.</param>
|
|
103
|
+
void IPeer.enqueue(RequestType requestType, RequestRole requestRole, OperationRequest operationRequest, Action<OperationResponse> onOperationResponse, string authToken, string secretKey, GNHashtable customTags, string gameId)
|
|
104
|
+
{
|
|
105
|
+
if (!this.isUse)
|
|
106
|
+
{
|
|
107
|
+
GNDebug.logError("[GN] Server Settings don't setup to use this to send operation request.");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
var operationPending = new OperationPending(requestType, requestRole, operationRequest, onOperationResponse, authToken, secretKey, customTags, gameId);
|
|
112
|
+
this.operationPendingQueue.Enqueue(operationPending);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/// <summary>
|
|
116
|
+
/// Checks if this peer is in use.
|
|
117
|
+
/// </summary>
|
|
118
|
+
/// <returns>True if the peer is in use, otherwise false.</returns>
|
|
119
|
+
bool IPeer.isUsing()
|
|
120
|
+
{
|
|
121
|
+
return this.isUse;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/// <summary>
|
|
125
|
+
/// Processes pending operations and handles responses and timeouts.
|
|
126
|
+
/// </summary>
|
|
127
|
+
public virtual void service()
|
|
128
|
+
{
|
|
129
|
+
if (!this.isUse) return;
|
|
130
|
+
|
|
131
|
+
// Check for timed-out operations.
|
|
132
|
+
if (this.checkTimeoutOperationPending < UnityEngine.Time.time)
|
|
133
|
+
{
|
|
134
|
+
this.checkTimeoutOperationPending = UnityEngine.Time.time + 0.1f;
|
|
135
|
+
|
|
136
|
+
if (this.operationWaitingResponseDict.Count != 0)
|
|
137
|
+
{
|
|
138
|
+
var gnArrayLst = new List<GNArray>();
|
|
139
|
+
|
|
140
|
+
foreach (var operationPendingPair in this.operationWaitingResponseDict)
|
|
141
|
+
{
|
|
142
|
+
var operationPending = operationPendingPair.Value;
|
|
143
|
+
|
|
144
|
+
if (operationPending.isTimeout())
|
|
145
|
+
{
|
|
146
|
+
var gnArray = new GNArray();
|
|
147
|
+
|
|
148
|
+
gnArray.add((int)ReturnCode.OperationTimeout);
|
|
149
|
+
gnArray.add(null);
|
|
150
|
+
gnArray.add(operationPending.getOperationRequest().getRequestId());
|
|
151
|
+
gnArray.add(operationPending.getOperationRequest().isEncrypted());
|
|
152
|
+
|
|
153
|
+
gnArrayLst.Add(gnArray);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
if (gnArrayLst.Count != 0)
|
|
158
|
+
{
|
|
159
|
+
foreach (var gnArray in gnArrayLst)
|
|
160
|
+
{
|
|
161
|
+
this.onResponseHandler(gnArray, gnArray.getBool(3));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
// Send the next pending message.
|
|
168
|
+
if (this.nextSendMsgTimer < UnityEngine.Time.time)
|
|
169
|
+
{
|
|
170
|
+
if (this.operationPendingQueue.Count != 0)
|
|
171
|
+
{
|
|
172
|
+
this.nextSendMsgTimer = UnityEngine.Time.time + this.perMsgTimer;
|
|
173
|
+
|
|
174
|
+
var operationPending = this.operationPendingQueue.Dequeue();
|
|
175
|
+
|
|
176
|
+
this.send(operationPending);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/// <summary>
|
|
182
|
+
/// Handles responses from the server.
|
|
183
|
+
/// </summary>
|
|
184
|
+
/// <param name="obj">The response object.</param>
|
|
185
|
+
/// <param name="isEncrypted">Indicates if the response is encrypted.</param>
|
|
186
|
+
internal void onResponseHandler(GNArray obj, bool isEncrypted)
|
|
187
|
+
{
|
|
188
|
+
var responseId = obj.getInt(2);
|
|
189
|
+
|
|
190
|
+
if (this.operationWaitingResponseDict.ContainsKey(responseId))
|
|
191
|
+
{
|
|
192
|
+
var operationPending = this.operationWaitingResponseDict[responseId];
|
|
193
|
+
operationPending.onRecv();
|
|
194
|
+
|
|
195
|
+
this.operationWaitingResponseDict.Remove(responseId);
|
|
196
|
+
|
|
197
|
+
var returnCode = obj.getInt(0);
|
|
198
|
+
|
|
199
|
+
GNHashtable parameters = null;
|
|
200
|
+
string debugMessage = null;
|
|
201
|
+
GNArray array = null;
|
|
202
|
+
|
|
203
|
+
if (returnCode == ReturnCode.Ok) parameters = obj.getGNHashtable(1);
|
|
204
|
+
else if (returnCode == ReturnCode.InvalidRequestParameters) array = obj.getGNArray(1);
|
|
205
|
+
else if (returnCode == ReturnCode.OperationNotAuthorized)
|
|
206
|
+
{
|
|
207
|
+
|
|
208
|
+
}
|
|
209
|
+
else debugMessage = obj.getString(1);
|
|
210
|
+
|
|
211
|
+
var operationRequest = operationPending.getOperationRequest();
|
|
212
|
+
var operationResponse = new OperationResponse(operationRequest.getOperationCode(), operationRequest.getRequestId(), isEncrypted);
|
|
213
|
+
|
|
214
|
+
operationResponse.setReturnCode(returnCode);
|
|
215
|
+
operationResponse.setDebugMessage(debugMessage);
|
|
216
|
+
operationResponse.setParameters(parameters);
|
|
217
|
+
|
|
218
|
+
//if (!parameters.containsKey(GNParameterCode.CustomTags)) parameters.add(GNParameterCode.CustomTags, customTags);
|
|
219
|
+
|
|
220
|
+
if (array != null)
|
|
221
|
+
{
|
|
222
|
+
var invalidMembers = new InvalidMember[array.count()];
|
|
223
|
+
for (var i = 0; i < array.count(); i++)
|
|
224
|
+
{
|
|
225
|
+
var arrChild = array.getGNArray(i);
|
|
226
|
+
|
|
227
|
+
invalidMembers[i] = new InvalidMember(arrChild.getString(0), (InvalidMemberType)arrChild.getInt(1));
|
|
228
|
+
}
|
|
229
|
+
operationResponse.setInvalidMembers(invalidMembers);
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (!operationResponse.hasError())
|
|
233
|
+
{
|
|
234
|
+
this.addPing(operationPending.getExecuteTimerInMs());
|
|
235
|
+
|
|
236
|
+
if (parameters != null)
|
|
237
|
+
{
|
|
238
|
+
if (parameters.containsKey(ParameterCode.AuthToken))
|
|
239
|
+
{
|
|
240
|
+
var authToken = parameters.getString(ParameterCode.AuthToken);
|
|
241
|
+
GNNetwork.getAuthenticateStatus().setAuthToken(authToken);
|
|
242
|
+
UnityEngine.PlayerPrefs.SetString(GNNetwork.AUTH_TOKEN_KEY, authToken);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
if (parameters.containsKey(ParameterCode.UserId))
|
|
246
|
+
{
|
|
247
|
+
var userId = parameters.getString(ParameterCode.UserId);
|
|
248
|
+
GNNetwork.getAuthenticateStatus().setUserId(userId);
|
|
249
|
+
UnityEngine.PlayerPrefs.SetString(GNNetwork.USER_ID_KEY, userId);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
if (parameters.containsKey(ParameterCode.Ts))
|
|
253
|
+
{
|
|
254
|
+
GNNetwork.peer.setServerTimeMilliseconds(parameters.getLong(ParameterCode.Ts, DateTimeOffset.UtcNow.ToUnixTimeMilliseconds()));
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
GNDebug.log("[GN RECV] " + operationResponse.ToString());
|
|
260
|
+
|
|
261
|
+
operationPending.getCallback()?.Invoke(operationResponse);
|
|
262
|
+
}
|
|
263
|
+
else
|
|
264
|
+
{
|
|
265
|
+
GNDebug.logError("[GN] OnResponseHandler, unavailable request id " + obj);
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/// <summary>
|
|
270
|
+
/// Sends the given operation request.
|
|
271
|
+
/// </summary>
|
|
272
|
+
/// <param name="operationPending">The operation request to be sent.</param>
|
|
273
|
+
internal virtual void send(OperationPending operationPending)
|
|
274
|
+
{
|
|
275
|
+
operationPending.onSend();
|
|
276
|
+
|
|
277
|
+
var operationRequest = operationPending.getOperationRequest();
|
|
278
|
+
|
|
279
|
+
if (operationRequest.getRequestId() != -1)
|
|
280
|
+
{
|
|
281
|
+
operationRequest.setRequestId(PeerBase.requestId++);
|
|
282
|
+
|
|
283
|
+
if (operationPending.getCallback() != null)
|
|
284
|
+
{
|
|
285
|
+
this.operationWaitingResponseDict[operationRequest.getRequestId()] = operationPending;
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/// <summary>
|
|
291
|
+
/// Adds a ping measurement for the current operation.
|
|
292
|
+
/// </summary>
|
|
293
|
+
/// <param name="value">The ping value in milliseconds.</param>
|
|
294
|
+
private void addPing(float value)
|
|
295
|
+
{
|
|
296
|
+
if (this.pingLst.Count > 10)
|
|
297
|
+
this.pingLst.Dequeue();
|
|
298
|
+
|
|
299
|
+
this.pingLst.Enqueue(value / 2);
|
|
300
|
+
this.ping = (int)(this.pingLst.Average() * 1000);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 42b0b6a0bb4033e48b899110d30e4e35
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 42b0b6a0bb4033e48b899110d30e4e35
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|