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
package/Runtime/GNNetwork.cs
CHANGED
|
@@ -1,182 +1,501 @@
|
|
|
1
|
-
namespace XmobiTea.GN
|
|
2
|
-
{
|
|
3
|
-
using System;
|
|
4
|
-
using
|
|
5
|
-
using XmobiTea.GN.Common;
|
|
6
|
-
using XmobiTea.GN.Config;
|
|
7
|
-
using XmobiTea.GN.Constant;
|
|
8
|
-
using XmobiTea.GN.Entity;
|
|
9
|
-
using XmobiTea.GN.Entity.Request;
|
|
10
|
-
using XmobiTea.GN.Entity.Response;
|
|
11
|
-
using XmobiTea.GN.Logger;
|
|
12
|
-
using XmobiTea.GN.Networking;
|
|
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
|
-
GNNetwork.
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
GNNetwork.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
GNNetwork.
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
GNNetwork.
|
|
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
|
-
|
|
1
|
+
namespace XmobiTea.GN
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using System.Threading.Tasks;
|
|
5
|
+
using XmobiTea.GN.Common;
|
|
6
|
+
using XmobiTea.GN.Config;
|
|
7
|
+
using XmobiTea.GN.Constant;
|
|
8
|
+
using XmobiTea.GN.Entity;
|
|
9
|
+
using XmobiTea.GN.Entity.Request;
|
|
10
|
+
using XmobiTea.GN.Entity.Response;
|
|
11
|
+
using XmobiTea.GN.Logger;
|
|
12
|
+
using XmobiTea.GN.Networking;
|
|
13
|
+
|
|
14
|
+
/// <summary>
|
|
15
|
+
/// Static class GNNetwork handles all the networking logic, including socket and HTTP communication.
|
|
16
|
+
/// </summary>
|
|
17
|
+
public static partial class GNNetwork
|
|
18
|
+
{
|
|
19
|
+
/// <summary>
|
|
20
|
+
/// Current SDK version.
|
|
21
|
+
/// </summary>
|
|
22
|
+
private const string GN_VERSION = "2.4";
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
/// Key for storing authentication token in PlayerPrefs.
|
|
26
|
+
/// </summary>
|
|
27
|
+
internal const string AUTH_TOKEN_KEY = "[GN]_AUTH_TOKEN_KEY";
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
/// Key for storing user ID in PlayerPrefs.
|
|
31
|
+
/// </summary>
|
|
32
|
+
internal const string USER_ID_KEY = "[GN]_USER_ID_KEY";
|
|
33
|
+
|
|
34
|
+
/// <summary>
|
|
35
|
+
/// Key for storing game ID in PlayerPrefs.
|
|
36
|
+
/// </summary>
|
|
37
|
+
internal const string GAME_ID_KEY = "[GN]_GAME_ID_KEY";
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
/// Holds GN server settings loaded from resources.
|
|
41
|
+
/// </summary>
|
|
42
|
+
public static GNServerSettings gnServerSettings { get; private set; }
|
|
43
|
+
|
|
44
|
+
/// <summary>
|
|
45
|
+
/// Instance of the NetworkingPeer for handling socket connections.
|
|
46
|
+
/// </summary>
|
|
47
|
+
internal static NetworkingPeer peer { get; private set; }
|
|
48
|
+
|
|
49
|
+
/// <summary>
|
|
50
|
+
/// Gets the current ping in milliseconds.
|
|
51
|
+
/// </summary>
|
|
52
|
+
/// <returns>The current ping value, or -1 if no peer exists.</returns>
|
|
53
|
+
public static int getPing() => GNNetwork.peer != null ? GNNetwork.peer.getPing() : -1;
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
/// Gets the current socket session ID.
|
|
57
|
+
/// </summary>
|
|
58
|
+
/// <returns>The socket session ID, or null if not connected.</returns>
|
|
59
|
+
public static string getSocketSId() => GNNetwork.peer != null ? GNNetwork.peer.getClientId() : null;
|
|
60
|
+
|
|
61
|
+
/// <summary>
|
|
62
|
+
/// Send Request auth socket to use socket
|
|
63
|
+
/// </summary>
|
|
64
|
+
public static void sendRequestAuthSocket() => GNNetwork.peer.sendRequestAuthSocket();
|
|
65
|
+
|
|
66
|
+
/// <summary>
|
|
67
|
+
/// Checks if the socket connection is active.
|
|
68
|
+
/// </summary>
|
|
69
|
+
/// <returns>True if the socket is connected; otherwise, false.</returns>
|
|
70
|
+
public static bool isSocketConnected() => !string.IsNullOrEmpty(GNNetwork.getSocketSId());
|
|
71
|
+
|
|
72
|
+
/// <summary>
|
|
73
|
+
/// Gets the server's current timestamp in milliseconds.
|
|
74
|
+
/// </summary>
|
|
75
|
+
/// <returns>The server's current timestamp, or the local UTC timestamp if no peer exists.</returns>
|
|
76
|
+
public static long getServerTimestamp() => GNNetwork.peer != null ? GNNetwork.peer.getServerTimestamp() : DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
|
77
|
+
|
|
78
|
+
/// <summary>
|
|
79
|
+
/// Gets the current authentication status of the connection.
|
|
80
|
+
/// </summary>
|
|
81
|
+
/// <returns>The current <see cref="AuthenticateStatus"/> of the peer.</returns>
|
|
82
|
+
public static AuthenticateStatus getAuthenticateStatus() => GNNetwork.peer.authenticateStatus;
|
|
83
|
+
|
|
84
|
+
/// <summary>
|
|
85
|
+
/// Gets the current override gameId
|
|
86
|
+
/// </summary>
|
|
87
|
+
/// <returns></returns>
|
|
88
|
+
public static string getGameId() => GNNetwork.peer.gameId;
|
|
89
|
+
|
|
90
|
+
/// <summary>
|
|
91
|
+
/// Gets the current platform of the application.
|
|
92
|
+
/// </summary>
|
|
93
|
+
/// <returns>The current runtime platform.</returns>
|
|
94
|
+
public static UnityEngine.RuntimePlatform getPlatform() => UnityEngine.Application.platform;
|
|
95
|
+
|
|
96
|
+
/// <summary>
|
|
97
|
+
/// Static constructor initializes the GNNetwork class.
|
|
98
|
+
/// </summary>
|
|
99
|
+
static GNNetwork()
|
|
100
|
+
{
|
|
101
|
+
GNNetwork.initServerSettings();
|
|
102
|
+
GNNetwork.initGNDebug();
|
|
103
|
+
|
|
104
|
+
if (!UnityEngine.Application.isPlaying) return;
|
|
105
|
+
|
|
106
|
+
GNDebug.log("GNNetwork init on Unity. Version: " + GNNetwork.getClientSdkVersion());
|
|
107
|
+
|
|
108
|
+
GNNetwork.initGNSocketObject();
|
|
109
|
+
|
|
110
|
+
GNNetwork.peer.authenticateStatus.setAuthToken(UnityEngine.PlayerPrefs.GetString(GNNetwork.AUTH_TOKEN_KEY, string.Empty));
|
|
111
|
+
GNNetwork.peer.authenticateStatus.setUserId(UnityEngine.PlayerPrefs.GetString(GNNetwork.USER_ID_KEY, string.Empty));
|
|
112
|
+
GNNetwork.peer.gameId = UnityEngine.PlayerPrefs.GetString(GNNetwork.GAME_ID_KEY, string.Empty);
|
|
113
|
+
|
|
114
|
+
GNNetwork.authenticate = new AuthenticateApi();
|
|
115
|
+
GNNetwork.characterPlayer = new CharacterPlayerApi();
|
|
116
|
+
GNNetwork.content = new ContentApi();
|
|
117
|
+
GNNetwork.dashboard = new DashboardApi();
|
|
118
|
+
GNNetwork.gamePlayer = new GamePlayerApi();
|
|
119
|
+
GNNetwork.group = new GroupApi();
|
|
120
|
+
GNNetwork.inventory = new InventoryApi();
|
|
121
|
+
GNNetwork.masterPlayer = new MasterPlayerApi();
|
|
122
|
+
GNNetwork.storeInventory = new StoreInventoryApi();
|
|
123
|
+
GNNetwork.multiplayer = new MultiplayerApi();
|
|
124
|
+
GNNetwork.cloudScript = new CloudScriptApi();
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/// <summary>
|
|
128
|
+
/// Gets the current SDK version.
|
|
129
|
+
/// </summary>
|
|
130
|
+
/// <returns>The current SDK version as a string.</returns>
|
|
131
|
+
public static string getClientSdkVersion() => GNNetwork.GN_VERSION;
|
|
132
|
+
|
|
133
|
+
/// <summary>
|
|
134
|
+
/// Initializes server settings from resources.
|
|
135
|
+
/// </summary>
|
|
136
|
+
private static void initServerSettings()
|
|
137
|
+
{
|
|
138
|
+
GNNetwork.gnServerSettings = UnityEngine.Resources.Load(GNServerSettings.ResourcesPath) as GNServerSettings;
|
|
139
|
+
if (GNNetwork.gnServerSettings == null)
|
|
140
|
+
{
|
|
141
|
+
#if UNITY_EDITOR
|
|
142
|
+
UnityEditor.EditorApplication.ExecuteMenuItem("XmobiTea GN/Open Settings");
|
|
143
|
+
GNNetwork.gnServerSettings = UnityEngine.Resources.Load(GNServerSettings.ResourcesPath) as GNServerSettings;
|
|
144
|
+
if (GNNetwork.gnServerSettings == null) throw new NullReferenceException("Null GN Server Settings, please find it now");
|
|
145
|
+
#endif
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/// <summary>
|
|
150
|
+
/// Initializes GN Debug settings based on the loaded server settings.
|
|
151
|
+
/// </summary>
|
|
152
|
+
private static void initGNDebug()
|
|
153
|
+
{
|
|
154
|
+
if (GNNetwork.gnServerSettings == null) throw new NullReferenceException("Null GN Server Settings, please find it now");
|
|
155
|
+
|
|
156
|
+
GNDebug.logType = GNNetwork.gnServerSettings.getLogType();
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/// <summary>
|
|
160
|
+
/// Initializes the socket connection object and its corresponding service update GameObject.
|
|
161
|
+
/// </summary>
|
|
162
|
+
private static void initGNSocketObject()
|
|
163
|
+
{
|
|
164
|
+
var peer = new NetworkingPeer();
|
|
165
|
+
|
|
166
|
+
peer.initPeer();
|
|
167
|
+
|
|
168
|
+
GNNetwork.peer = peer;
|
|
169
|
+
|
|
170
|
+
var serviceUpdate = new UnityEngine.GameObject("[GN] ServiceUpdate").AddComponent<Unity.ServiceUpdate>();
|
|
171
|
+
UnityEngine.GameObject.DontDestroyOnLoad(serviceUpdate.gameObject);
|
|
172
|
+
|
|
173
|
+
serviceUpdate.peer = peer;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
public static void setNewAuthenticateStatus(AuthenticateStatus authenticateStatus)
|
|
177
|
+
{
|
|
178
|
+
UnityEngine.PlayerPrefs.SetString(GNNetwork.AUTH_TOKEN_KEY, authenticateStatus.getAuthToken());
|
|
179
|
+
UnityEngine.PlayerPrefs.SetString(GNNetwork.USER_ID_KEY, authenticateStatus.getUserId());
|
|
180
|
+
|
|
181
|
+
GNNetwork.peer.authenticateStatus.setAuthToken(authenticateStatus.getAuthToken());
|
|
182
|
+
GNNetwork.peer.authenticateStatus.setUserId(authenticateStatus.getUserId());
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
public static void setGameId(string gameId)
|
|
186
|
+
{
|
|
187
|
+
UnityEngine.PlayerPrefs.SetString(GNNetwork.GAME_ID_KEY, gameId);
|
|
188
|
+
|
|
189
|
+
GNNetwork.peer.gameId = gameId;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/// <summary>
|
|
193
|
+
/// Sends a request via socket.
|
|
194
|
+
/// </summary>
|
|
195
|
+
/// <param name="requestType">The type of the request.</param>
|
|
196
|
+
/// <param name="requestRole">The role of the request.</param>
|
|
197
|
+
/// <param name="request">The request data to send.</param>
|
|
198
|
+
/// <param name="onResponse">Optional callback for handling the response.</param>
|
|
199
|
+
/// <param name="overrideAuthToken">Optional token override for the request.</param>
|
|
200
|
+
/// <param name="overrideSecretKey">Optional secret key override for the request.</param>
|
|
201
|
+
/// <param name="customTags">Optional custom tags for the request.</param>
|
|
202
|
+
public static void sendViaSocket(RequestType requestType, RequestRole requestRole, OperationRequest request, Action<OperationResponse> onResponse = null, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null)
|
|
203
|
+
{
|
|
204
|
+
GNNetwork.peer.sendViaSocket(requestType, requestRole, request, onResponse, overrideAuthToken, overrideSecretKey, customTags);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/// <summary>
|
|
208
|
+
/// Sends a request via socket asynchronously and returns the response.
|
|
209
|
+
/// </summary>
|
|
210
|
+
/// <param name="requestType">The type of the request.</param>
|
|
211
|
+
/// <param name="requestRole">The role of the request.</param>
|
|
212
|
+
/// <param name="request">The request data.</param>
|
|
213
|
+
/// <param name="overrideAuthToken">Optional token to override the default authentication token.</param>
|
|
214
|
+
/// <param name="overrideSecretKey">Optional secret key to override the default key.</param>
|
|
215
|
+
/// <param name="customTags">Optional custom tags for the request.</param>
|
|
216
|
+
/// <returns>A Task that resolves with the operation response.</returns>
|
|
217
|
+
public static Task<OperationResponse> sendViaSocketAsync(RequestType requestType, RequestRole requestRole, OperationRequest request, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null)
|
|
218
|
+
{
|
|
219
|
+
var taskCompletionSource = new TaskCompletionSource<OperationResponse>();
|
|
220
|
+
|
|
221
|
+
GNNetwork.sendViaSocket(requestType, requestRole, request, response =>
|
|
222
|
+
{
|
|
223
|
+
taskCompletionSource.SetResult(response);
|
|
224
|
+
}, overrideAuthToken, overrideSecretKey, customTags);
|
|
225
|
+
|
|
226
|
+
return taskCompletionSource.Task;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/// <summary>
|
|
230
|
+
/// Sends a request via HTTP.
|
|
231
|
+
/// </summary>
|
|
232
|
+
/// <param name="requestType">The type of the request.</param>
|
|
233
|
+
/// <param name="requestRole">The role of the request.</param>
|
|
234
|
+
/// <param name="request">The request data.</param>
|
|
235
|
+
/// <param name="onResponse">Optional callback to handle the response.</param>
|
|
236
|
+
/// <param name="overrideAuthToken">Optional token to override the default authentication token.</param>
|
|
237
|
+
/// <param name="overrideSecretKey">Optional secret key to override the default key.</param>
|
|
238
|
+
/// <param name="customTags">Optional custom tags for the request.</param>
|
|
239
|
+
public static void sendViaHttp(RequestType requestType, RequestRole requestRole, OperationRequest request, Action<OperationResponse> onResponse = null, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null)
|
|
240
|
+
{
|
|
241
|
+
GNNetwork.peer.sendViaHttp(requestType, requestRole, request, onResponse, overrideAuthToken, overrideSecretKey, customTags);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/// <summary>
|
|
245
|
+
/// Sends a request via HTTP asynchronously and returns the response.
|
|
246
|
+
/// </summary>
|
|
247
|
+
/// <param name="requestType">The type of the request.</param>
|
|
248
|
+
/// <param name="requestRole">The role of the request.</param>
|
|
249
|
+
/// <param name="request">The request data.</param>
|
|
250
|
+
/// <param name="overrideAuthToken">Optional token to override the default authentication token.</param>
|
|
251
|
+
/// <param name="overrideSecretKey">Optional secret key to override the default key.</param>
|
|
252
|
+
/// <param name="customTags">Optional custom tags for the request.</param>
|
|
253
|
+
/// <returns>A Task that resolves with the operation response.</returns>
|
|
254
|
+
public static Task<OperationResponse> sendViaHttpAsync(RequestType requestType, RequestRole requestRole, OperationRequest request, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null)
|
|
255
|
+
{
|
|
256
|
+
var taskCompletionSource = new TaskCompletionSource<OperationResponse>();
|
|
257
|
+
|
|
258
|
+
GNNetwork.sendViaHttp(requestType, requestRole, request, response =>
|
|
259
|
+
{
|
|
260
|
+
taskCompletionSource.SetResult(response);
|
|
261
|
+
}, overrideAuthToken, overrideSecretKey, customTags);
|
|
262
|
+
|
|
263
|
+
return taskCompletionSource.Task;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
/// <summary>
|
|
267
|
+
/// Sends a request via socket with strongly-typed request and response.
|
|
268
|
+
/// </summary>
|
|
269
|
+
/// <typeparam name="TRequest">The type of the request.</typeparam>
|
|
270
|
+
/// <typeparam name="TResponse">The type of the response.</typeparam>
|
|
271
|
+
/// <param name="request">The request object to send.</param>
|
|
272
|
+
/// <param name="onResponse">Optional callback to handle the response.</param>
|
|
273
|
+
/// <param name="overrideAuthToken">Optional token to override the default authentication token.</param>
|
|
274
|
+
/// <param name="overrideSecretKey">Optional secret key to override the default key.</param>
|
|
275
|
+
/// <param name="customTags">Optional custom tags for the request.</param>
|
|
276
|
+
public static void sendViaSocket<TRequest, TResponse>(TRequest request, Action<TResponse> onResponse = null, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null) where TRequest : CustomOperationRequest where TResponse : CustomOperationResponse, new()
|
|
277
|
+
{
|
|
278
|
+
GNNetwork.sendViaSocket(request.getRequestType(), request.getRequestRole(), request.build(), onResponse, overrideAuthToken, overrideSecretKey, customTags);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/// <summary>
|
|
282
|
+
/// Sends a request via socket asynchronously with strongly-typed request and response.
|
|
283
|
+
/// </summary>
|
|
284
|
+
/// <typeparam name="TRequest">The type of the request.</typeparam>
|
|
285
|
+
/// <typeparam name="TResponse">The type of the response.</typeparam>
|
|
286
|
+
/// <param name="request">The request object to send.</param>
|
|
287
|
+
/// <param name="overrideAuthToken">Optional token to override the default authentication token.</param>
|
|
288
|
+
/// <param name="overrideSecretKey">Optional secret key to override the default key.</param>
|
|
289
|
+
/// <param name="customTags">Optional custom tags for the request.</param>
|
|
290
|
+
/// <returns>A Task that resolves with the typed response.</returns>
|
|
291
|
+
public static Task<TResponse> sendViaSocketAsync<TRequest, TResponse>(TRequest request, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null) where TRequest : CustomOperationRequest where TResponse : CustomOperationResponse, new()
|
|
292
|
+
{
|
|
293
|
+
var taskCompletionSource = new TaskCompletionSource<TResponse>();
|
|
294
|
+
|
|
295
|
+
GNNetwork.sendViaSocket<TRequest, TResponse>(request, response =>
|
|
296
|
+
{
|
|
297
|
+
taskCompletionSource.SetResult(response);
|
|
298
|
+
}, overrideAuthToken, overrideSecretKey, customTags);
|
|
299
|
+
|
|
300
|
+
return taskCompletionSource.Task;
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Similar comments for other methods (HTTP variants and generics)
|
|
304
|
+
|
|
305
|
+
/// <summary>
|
|
306
|
+
/// Sends a request via HTTP with strongly-typed request and response.
|
|
307
|
+
/// </summary>
|
|
308
|
+
/// <typeparam name="TRequest">The type of the request.</typeparam>
|
|
309
|
+
/// <typeparam name="TResponse">The type of the response.</typeparam>
|
|
310
|
+
/// <param name="request">The request object to send.</param>
|
|
311
|
+
/// <param name="onResponse">Optional callback to handle the response.</param>
|
|
312
|
+
/// <param name="overrideAuthToken">Optional token to override the default authentication token.</param>
|
|
313
|
+
/// <param name="overrideSecretKey">Optional secret key to override the default key.</param>
|
|
314
|
+
/// <param name="customTags">Optional custom tags for the request.</param>
|
|
315
|
+
public static void sendViaHttp<TRequest, TResponse>(TRequest request, Action<TResponse> onResponse = null, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null) where TRequest : CustomOperationRequest where TResponse : CustomOperationResponse, new()
|
|
316
|
+
{
|
|
317
|
+
GNNetwork.sendViaHttp(request.getRequestType(), request.getRequestRole(), request.build(), onResponse, overrideAuthToken, overrideSecretKey, customTags);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
/// <summary>
|
|
321
|
+
/// Sends a request via HTTP asynchronously with strongly-typed request and response.
|
|
322
|
+
/// </summary>
|
|
323
|
+
/// <typeparam name="TRequest">The type of the request.</typeparam>
|
|
324
|
+
/// <typeparam name="TResponse">The type of the response.</typeparam>
|
|
325
|
+
/// <param name="request">The request object to send.</param>
|
|
326
|
+
/// <param name="overrideAuthToken">Optional token to override the default authentication token.</param>
|
|
327
|
+
/// <param name="overrideSecretKey">Optional secret key to override the default key.</param>
|
|
328
|
+
/// <param name="customTags">Optional custom tags for the request.</param>
|
|
329
|
+
/// <returns>A Task that resolves with the typed response.</returns>
|
|
330
|
+
public static Task<TResponse> sendViaHttpAsync<TRequest, TResponse>(TRequest request, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null) where TRequest : CustomOperationRequest where TResponse : CustomOperationResponse, new()
|
|
331
|
+
{
|
|
332
|
+
var taskCompletionSource = new TaskCompletionSource<TResponse>();
|
|
333
|
+
|
|
334
|
+
GNNetwork.sendViaHttp<TRequest, TResponse>(request, response =>
|
|
335
|
+
{
|
|
336
|
+
taskCompletionSource.SetResult(response);
|
|
337
|
+
}, overrideAuthToken, overrideSecretKey, customTags);
|
|
338
|
+
|
|
339
|
+
return taskCompletionSource.Task;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
/// <summary>
|
|
343
|
+
/// Sends a request via socket with a strongly-typed response.
|
|
344
|
+
/// </summary>
|
|
345
|
+
/// <typeparam name="TResponse">The type of the response object.</typeparam>
|
|
346
|
+
/// <param name="requestType">The type of the request being sent.</param>
|
|
347
|
+
/// <param name="requestRole">The role of the request being sent.</param>
|
|
348
|
+
/// <param name="request">The request data to send.</param>
|
|
349
|
+
/// <param name="onResponse">Optional callback to handle the strongly-typed response.</param>
|
|
350
|
+
/// <param name="overrideAuthToken">Optional authentication token to override the default value.</param>
|
|
351
|
+
/// <param name="overrideSecretKey">Optional secret key to override the default value.</param>
|
|
352
|
+
/// <param name="customTags">Optional custom tags to send with the request.</param>
|
|
353
|
+
public static void sendViaSocket<TResponse>(RequestType requestType, RequestRole requestRole, OperationRequest request, Action<TResponse> onResponse = null, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null) where TResponse : CustomOperationResponse, new()
|
|
354
|
+
{
|
|
355
|
+
GNNetwork.sendViaSocket(requestType, requestRole, request, response =>
|
|
356
|
+
{
|
|
357
|
+
if (response == null) return;
|
|
358
|
+
|
|
359
|
+
var customOperationResponse = new TResponse() { };
|
|
360
|
+
customOperationResponse.setupOperationResponse(response);
|
|
361
|
+
|
|
362
|
+
onResponse?.Invoke(customOperationResponse);
|
|
363
|
+
}, overrideAuthToken, overrideSecretKey, customTags);
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/// <summary>
|
|
367
|
+
/// Sends a request via socket asynchronously with a strongly-typed response.
|
|
368
|
+
/// </summary>
|
|
369
|
+
/// <typeparam name="TResponse">The type of the response object.</typeparam>
|
|
370
|
+
/// <param name="requestType">The type of the request being sent.</param>
|
|
371
|
+
/// <param name="requestRole">The role of the request being sent.</param>
|
|
372
|
+
/// <param name="request">The request data to send.</param>
|
|
373
|
+
/// <param name="overrideAuthToken">Optional authentication token to override the default value.</param>
|
|
374
|
+
/// <param name="overrideSecretKey">Optional secret key to override the default value.</param>
|
|
375
|
+
/// <param name="customTags">Optional custom tags to send with the request.</param>
|
|
376
|
+
/// <returns>A Task that resolves to the strongly-typed response.</returns>
|
|
377
|
+
public static Task<TResponse> sendViaSocketAsync<TResponse>(RequestType requestType, RequestRole requestRole, OperationRequest request, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null) where TResponse : CustomOperationResponse, new()
|
|
378
|
+
{
|
|
379
|
+
var taskCompletionSource = new TaskCompletionSource<TResponse>();
|
|
380
|
+
|
|
381
|
+
GNNetwork.sendViaSocket<TResponse>(requestType, requestRole, request, response =>
|
|
382
|
+
{
|
|
383
|
+
taskCompletionSource.SetResult(response);
|
|
384
|
+
}, overrideAuthToken, overrideSecretKey, customTags);
|
|
385
|
+
|
|
386
|
+
return taskCompletionSource.Task;
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
/// <summary>
|
|
390
|
+
/// Sends a request via HTTP with a strongly-typed response.
|
|
391
|
+
/// </summary>
|
|
392
|
+
/// <typeparam name="TResponse">The type of the response object.</typeparam>
|
|
393
|
+
/// <param name="requestType">The type of the request being sent.</param>
|
|
394
|
+
/// <param name="requestRole">The role of the request being sent.</param>
|
|
395
|
+
/// <param name="request">The request data to send.</param>
|
|
396
|
+
/// <param name="onResponse">Optional callback to handle the strongly-typed response.</param>
|
|
397
|
+
/// <param name="overrideAuthToken">Optional authentication token to override the default value.</param>
|
|
398
|
+
/// <param name="overrideSecretKey">Optional secret key to override the default value.</param>
|
|
399
|
+
/// <param name="customTags">Optional custom tags to send with the request.</param>
|
|
400
|
+
public static void sendViaHttp<TResponse>(RequestType requestType, RequestRole requestRole, OperationRequest request, Action<TResponse> onResponse = null, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null) where TResponse : CustomOperationResponse, new()
|
|
401
|
+
{
|
|
402
|
+
GNNetwork.sendViaHttp(requestType, requestRole, request, response =>
|
|
403
|
+
{
|
|
404
|
+
if (response == null) return;
|
|
405
|
+
|
|
406
|
+
var customOperationResponse = new TResponse() { };
|
|
407
|
+
customOperationResponse.setupOperationResponse(response);
|
|
408
|
+
|
|
409
|
+
onResponse?.Invoke(customOperationResponse);
|
|
410
|
+
}, overrideAuthToken, overrideSecretKey, customTags);
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
/// <summary>
|
|
414
|
+
/// Sends a request via HTTP asynchronously with a strongly-typed response.
|
|
415
|
+
/// </summary>
|
|
416
|
+
/// <typeparam name="TResponse">The type of the response object.</typeparam>
|
|
417
|
+
/// <param name="requestType">The type of the request being sent.</param>
|
|
418
|
+
/// <param name="requestRole">The role of the request being sent.</param>
|
|
419
|
+
/// <param name="request">The request data to send.</param>
|
|
420
|
+
/// <param name="overrideAuthToken">Optional authentication token to override the default value.</param>
|
|
421
|
+
/// <param name="overrideSecretKey">Optional secret key to override the default value.</param>
|
|
422
|
+
/// <param name="customTags">Optional custom tags to send with the request.</param>
|
|
423
|
+
/// <returns>A Task that resolves to the strongly-typed response.</returns>
|
|
424
|
+
public static Task<TResponse> sendViaHttpAsync<TResponse>(RequestType requestType, RequestRole requestRole, OperationRequest request, string overrideAuthToken = null, string overrideSecretKey = null, GNHashtable customTags = null) where TResponse : CustomOperationResponse, new()
|
|
425
|
+
{
|
|
426
|
+
var taskCompletionSource = new TaskCompletionSource<TResponse>();
|
|
427
|
+
|
|
428
|
+
GNNetwork.sendViaHttp<TResponse>(requestType, requestRole, request, response =>
|
|
429
|
+
{
|
|
430
|
+
taskCompletionSource.SetResult(response);
|
|
431
|
+
}, overrideAuthToken, overrideSecretKey, customTags);
|
|
432
|
+
|
|
433
|
+
return taskCompletionSource.Task;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/// <summary>
|
|
437
|
+
/// Connects to the socket server.
|
|
438
|
+
/// </summary>
|
|
439
|
+
/// <param name="_onSocketConnect">Optional callback invoked when the socket is connected.</param>
|
|
440
|
+
public static void connectSocket(Action _onSocketConnect = null)
|
|
441
|
+
{
|
|
442
|
+
GNNetwork.peer.connectSocket(_onSocketConnect);
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
/// <summary>
|
|
446
|
+
/// Disconnects from the socket server.
|
|
447
|
+
/// </summary>
|
|
448
|
+
/// <param name="_onSocketDisconnect">Optional callback invoked when the socket is disconnected.</param>
|
|
449
|
+
public static void disconnectSocket(Action _onSocketDisconnect = null)
|
|
450
|
+
{
|
|
451
|
+
GNNetwork.peer.disconnectSocket(_onSocketDisconnect);
|
|
452
|
+
}
|
|
453
|
+
|
|
454
|
+
/// <summary>
|
|
455
|
+
/// Subscribes to event handlers for socket events.
|
|
456
|
+
/// </summary>
|
|
457
|
+
/// <param name="_onEventHandler">The handler to invoke when an event occurs.</param>
|
|
458
|
+
public static void setOnEventHandler(Action<OperationEvent> _onEventHandler)
|
|
459
|
+
{
|
|
460
|
+
GNNetwork.peer.setOnEventHandler(_onEventHandler);
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
/// <summary>
|
|
464
|
+
/// Subscribes a handler to be invoked when the socket connects successfully.
|
|
465
|
+
/// </summary>
|
|
466
|
+
/// <param name="onConnectHandler">The action to execute when the socket connects.</param>
|
|
467
|
+
public static void subscriberOnConnectHandler(Action onConnectHandler)
|
|
468
|
+
{
|
|
469
|
+
GNNetwork.peer.setOnConnectHandler(onConnectHandler);
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
/// <summary>
|
|
473
|
+
/// Subscribes a handler to be invoked when the socket disconnects.
|
|
474
|
+
/// </summary>
|
|
475
|
+
/// <param name="onDisconnectHandler">The action to execute when the socket disconnects.</param>
|
|
476
|
+
public static void subscriberOnDisconnectHandler(Action onDisconnectHandler)
|
|
477
|
+
{
|
|
478
|
+
GNNetwork.peer.setOnDisconnectHandler(onDisconnectHandler);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
/// <summary>
|
|
482
|
+
/// Unsubscribes a previously subscribed handler for socket connection events.
|
|
483
|
+
/// </summary>
|
|
484
|
+
/// <param name="onConnectHandler">The action to remove from connection event handlers.</param>
|
|
485
|
+
public static void unscriberOnConnectHandler(Action onConnectHandler)
|
|
486
|
+
{
|
|
487
|
+
GNNetwork.peer.removeOnConnectHandler(onConnectHandler);
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
/// <summary>
|
|
491
|
+
/// Unsubscribes a previously subscribed handler for socket disconnection events.
|
|
492
|
+
/// </summary>
|
|
493
|
+
/// <param name="onDisconnectHandler">The action to remove from disconnection event handlers.</param>
|
|
494
|
+
public static void unsubscriberOnDisconnectHandler(Action onDisconnectHandler)
|
|
495
|
+
{
|
|
496
|
+
GNNetwork.peer.removeOnDisconnectHandler(onDisconnectHandler);
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
}
|