com.xmobitea.changx.gn-unity 2.0.2 → 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 +42 -322
- package/Runtime/Common/GNArray.cs +120 -35
- package/Runtime/Common/GNData.cs +19 -6
- package/Runtime/Common/GNHashtable.cs +174 -11
- package/Runtime/Common/IGNData.cs +11 -2
- package/Runtime/Config/GNServerSettings.cs +136 -92
- package/Runtime/Constant/Commands.cs +82 -19
- package/Runtime/Constant/EnumType/GoogleLoginType.cs +5 -5
- package/Runtime/Constant/EnumType/GroupStatus.cs +7 -7
- package/Runtime/Constant/EnumType/ItemType.cs +5 -5
- package/Runtime/Constant/EnumType/MatchmakingMemberStatus.cs +6 -6
- package/Runtime/Constant/EnumType/MatchmakingTicketStatus.cs +2 -2
- package/Runtime/Constant/EnumType/OwnerType.cs +3 -2
- package/Runtime/Constant/EnumType/PushPlatformType.cs +10 -0
- package/Runtime/Constant/EnumType/PushPlatformType.cs.meta +11 -0
- package/Runtime/Constant/EnumType/RequestType.cs +1 -0
- package/Runtime/Constant/EnumType/StoreReceiveType.cs +13 -0
- package/Runtime/Constant/EnumType/StoreReceiveType.cs.meta +11 -0
- package/Runtime/Constant/ErrorCode/GNErrorCode.cs +53 -48
- package/Runtime/Constant/EventCode.cs +29 -2
- package/Runtime/Constant/OperationCode.cs +249 -211
- package/Runtime/Constant/ParameterCode/GNParameterCode.cs +610 -466
- package/Runtime/Constant/ReturnCode.cs +50 -2
- package/Runtime/Entity/DataMember.cs +221 -3
- package/Runtime/Entity/GNMetadata.cs +46 -1
- package/Runtime/Entity/InvalidMember.cs +24 -5
- package/Runtime/Entity/Models/AuthenticateModels.cs +251 -207
- package/Runtime/Entity/Models/AuthenticateRequestModels.cs +153 -131
- package/Runtime/Entity/Models/AuthenticateResponseModels.cs +61 -51
- package/Runtime/Entity/Models/CharacterPlayerModels.cs +985 -849
- package/Runtime/Entity/Models/CharacterPlayerRequestModels.cs +957 -885
- package/Runtime/Entity/Models/CharacterPlayerResponseModels.cs +165 -150
- 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/ContentRequestModels.cs +129 -129
- package/Runtime/Entity/Models/ContentResponseModels.cs +24 -24
- package/Runtime/Entity/Models/DashboardModels.cs +1684 -1156
- package/Runtime/Entity/Models/DashboardRequestModels.cs +220 -147
- package/Runtime/Entity/Models/DashboardResponseModels.cs +92 -57
- package/Runtime/Entity/Models/GamePlayerModels.cs +1073 -933
- package/Runtime/Entity/Models/GamePlayerRequestModels.cs +939 -867
- package/Runtime/Entity/Models/GamePlayerResponseModels.cs +162 -147
- package/Runtime/Entity/Models/GenericModels.cs +102 -102
- package/Runtime/Entity/Models/GroupModels.cs +812 -676
- package/Runtime/Entity/Models/GroupRequestModels.cs +741 -669
- package/Runtime/Entity/Models/GroupResponseModels.cs +129 -114
- package/Runtime/Entity/Models/InventoryModels.cs +667 -558
- package/Runtime/Entity/Models/InventoryRequestModels.cs +626 -579
- package/Runtime/Entity/Models/InventoryResponseModels.cs +109 -99
- package/Runtime/Entity/Models/MasterPlayerModels.cs +1882 -1340
- package/Runtime/Entity/Models/MasterPlayerRequestModels.cs +1643 -1253
- package/Runtime/Entity/Models/MasterPlayerResponseModels.cs +293 -213
- package/Runtime/Entity/Models/MultiplayerModels.cs +293 -223
- package/Runtime/Entity/Models/MultiplayerRequestModels.cs +199 -149
- package/Runtime/Entity/Models/MultiplayerResponseModels.cs +10 -0
- package/Runtime/Entity/Models/StoreInventoryModels.cs +514 -323
- package/Runtime/Entity/Models/StoreInventoryRequestModels.cs +236 -165
- package/Runtime/Entity/Models/StoreInventoryResponseModels.cs +45 -30
- package/Runtime/Entity/OperationEvent.cs +43 -7
- package/Runtime/Entity/OperationHelper.cs +18 -2
- package/Runtime/Entity/OperationRequest.cs +80 -37
- package/Runtime/Entity/OperationResponse.cs +111 -63
- package/Runtime/Entity/Request/CustomOperationRequest.cs +53 -2
- package/Runtime/Entity/Response/CustomOperationResponse.cs +25 -4
- package/Runtime/GNNetwork.cs +333 -21
- package/Runtime/GNNetworkApi.cs +25 -13
- package/Runtime/GNNetworkAuthenticateApi.cs +531 -98
- package/Runtime/GNNetworkCharacterPlayerApi.cs +1587 -762
- package/Runtime/GNNetworkCloudScriptApi.cs +181 -0
- package/Runtime/GNNetworkCloudScriptApi.cs.meta +11 -0
- package/Runtime/GNNetworkContentApi.cs +238 -132
- package/Runtime/GNNetworkDashboardApi.cs +278 -117
- package/Runtime/GNNetworkGamePlayerApi.cs +1558 -747
- package/Runtime/GNNetworkGroupApi.cs +1228 -582
- package/Runtime/GNNetworkInventoryApi.cs +1048 -507
- package/Runtime/GNNetworkMasterPlayerApi.cs +2586 -1067
- package/Runtime/GNNetworkMultiplayerApi.cs +328 -147
- package/Runtime/GNNetworkStoreInventoryApi.cs +388 -162
- package/Runtime/Helper/CodeHelper.cs +45 -3
- package/Runtime/Helper/ConverterService.cs +240 -85
- package/Runtime/Logger/GNDebug.cs +46 -3
- package/Runtime/Networking/AuthenticateStatus.cs +30 -8
- package/Runtime/Networking/Handler/IServerEventHandler.cs +8 -8
- package/Runtime/Networking/Handler/OnCharacterPlayerFriendUpdateEventHandler.cs +31 -2
- package/Runtime/Networking/Handler/OnCharacterPlayerGroupUpdateEventHandler.cs +24 -3
- package/Runtime/Networking/Handler/OnGamePlayerFriendUpdateEventHandler.cs +24 -2
- package/Runtime/Networking/Handler/OnGamePlayerGroupUpdateEventHandler.cs +24 -2
- package/Runtime/Networking/Handler/OnGroupMemberUpdateEventHandler.cs +21 -2
- package/Runtime/Networking/Handler/OnGroupMessageUpdateEventHandler.cs +20 -2
- package/Runtime/Networking/Http/HttpPeer.cs +68 -25
- package/Runtime/Networking/Http/NetworkingHttpPeerBase.cs +44 -4
- package/Runtime/Networking/Http/NetworkingPeerHttpClientRequest.cs +63 -40
- package/Runtime/Networking/Http/NetworkingPeerHttpRequest.cs +43 -13
- package/Runtime/Networking/Http/NetworkingPeerUnityWebRequest.cs +72 -39
- package/Runtime/Networking/IPeer.cs +24 -2
- package/Runtime/Networking/NetworkingPeer.cs +64 -10
- package/Runtime/Networking/NetworkingPeerAPI.cs +20 -21
- package/Runtime/Networking/OperationPending.cs +79 -15
- package/Runtime/Networking/PeerBase.cs +86 -23
- package/Runtime/Networking/Socket/NetworkingPeerSocketV2.cs +57 -18
- package/Runtime/Networking/Socket/NetworkingPeerSocketV3.cs +70 -10
- package/Runtime/Networking/Socket/NetworkingSocketPeerBase.cs +165 -23
- package/Runtime/Networking/Socket/SocketPeer.cs +63 -12
- package/Runtime/Unity/ServiceCoroutine.cs +10 -0
- package/Runtime/Unity/ServiceCoroutine.cs.meta +11 -0
- package/Runtime/Unity/ServiceUpdate.cs +14 -1
- package/package.json +1 -1
|
@@ -8,34 +8,50 @@
|
|
|
8
8
|
using XmobiTea.GN.Entity;
|
|
9
9
|
using XmobiTea.GN.Logger;
|
|
10
10
|
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// Manages socket communication for the application.
|
|
13
|
+
/// </summary>
|
|
11
14
|
internal class SocketPeer : PeerBase
|
|
12
15
|
{
|
|
13
16
|
private NetworkingSocketPeerBase networkingSocketPeerBase;
|
|
14
|
-
|
|
15
|
-
|
|
16
17
|
private Dictionary<int, List<IServerEventHandler>> serverEventHandlersDict;
|
|
17
|
-
|
|
18
18
|
private Action<OperationEvent> _onEventHandler;
|
|
19
19
|
|
|
20
|
+
/// <summary>
|
|
21
|
+
/// Gets the client ID of the socket connection.
|
|
22
|
+
/// </summary>
|
|
23
|
+
/// <returns>The client ID as a string.</returns>
|
|
20
24
|
internal string getClientId()
|
|
21
25
|
{
|
|
22
26
|
return this.networkingSocketPeerBase?.clientId;
|
|
23
27
|
}
|
|
24
28
|
|
|
29
|
+
/// <summary>
|
|
30
|
+
/// Checks if the socket connection is established.
|
|
31
|
+
/// </summary>
|
|
32
|
+
/// <returns>True if connected, otherwise false.</returns>
|
|
25
33
|
internal bool isConnected()
|
|
26
34
|
{
|
|
27
35
|
return this.networkingSocketPeerBase.isWsConnected;
|
|
28
36
|
}
|
|
29
37
|
|
|
38
|
+
/// <summary>
|
|
39
|
+
/// Sends an authentication request via the socket.
|
|
40
|
+
/// </summary>
|
|
30
41
|
internal void sendRequestAuthSocket()
|
|
31
42
|
{
|
|
32
43
|
this.networkingSocketPeerBase.sendRequestAuthSocket();
|
|
33
44
|
}
|
|
34
45
|
|
|
46
|
+
/// <summary>
|
|
47
|
+
/// Subscribes server event handlers by scanning the current assembly.
|
|
48
|
+
/// </summary>
|
|
35
49
|
void subscriberServerEventHandler()
|
|
36
50
|
{
|
|
37
|
-
if (this.serverEventHandlersDict == null)
|
|
38
|
-
|
|
51
|
+
if (this.serverEventHandlersDict == null)
|
|
52
|
+
this.serverEventHandlersDict = new Dictionary<int, List<IServerEventHandler>>();
|
|
53
|
+
else
|
|
54
|
+
this.serverEventHandlersDict.Clear();
|
|
39
55
|
|
|
40
56
|
var type = typeof(IServerEventHandler);
|
|
41
57
|
var types = AppDomain.CurrentDomain.GetAssemblies()
|
|
@@ -65,6 +81,9 @@
|
|
|
65
81
|
}
|
|
66
82
|
}
|
|
67
83
|
|
|
84
|
+
/// <summary>
|
|
85
|
+
/// Initializes the socket object with server settings.
|
|
86
|
+
/// </summary>
|
|
68
87
|
internal override void initGNSocketObject()
|
|
69
88
|
{
|
|
70
89
|
var gnServerSettings = GNNetwork.gnServerSettings;
|
|
@@ -76,10 +95,13 @@
|
|
|
76
95
|
|
|
77
96
|
if (peerSocketVersion == PeerSocketVersion.V3)
|
|
78
97
|
{
|
|
98
|
+
#if UNITY_USING_BEST_HTTP
|
|
79
99
|
this.networkingSocketPeerBase = new NetworkingPeerSocketV3();
|
|
100
|
+
#endif
|
|
80
101
|
}
|
|
81
102
|
else
|
|
82
103
|
{
|
|
104
|
+
#if UNITY_USING_BEST_HTTP
|
|
83
105
|
this.networkingSocketPeerBase = new NetworkingPeerSocketV2();
|
|
84
106
|
|
|
85
107
|
if (peerSocketVersion == PeerSocketVersion.V2_v2)
|
|
@@ -90,8 +112,11 @@
|
|
|
90
112
|
{
|
|
91
113
|
((NetworkingPeerSocketV2)this.networkingSocketPeerBase).setServerVersion(BestHTTP.SocketIO.SupportedSocketIOVersions.v3);
|
|
92
114
|
}
|
|
115
|
+
#endif
|
|
93
116
|
}
|
|
94
117
|
|
|
118
|
+
if (this.networkingSocketPeerBase == null) throw new NullReferenceException("this.networkingSocketPeerBase null");
|
|
119
|
+
|
|
95
120
|
this.networkingSocketPeerBase.init(gnServerSettings.getSocketUrl(), gnServerSettings.getReconnectDelay(), gnServerSettings.getPingInterval(), gnServerSettings.getPingTimeout());
|
|
96
121
|
this.networkingSocketPeerBase.reInitNewSocket();
|
|
97
122
|
|
|
@@ -101,41 +126,65 @@
|
|
|
101
126
|
this.subscriberServerEventHandler();
|
|
102
127
|
}
|
|
103
128
|
|
|
129
|
+
/// <summary>
|
|
130
|
+
/// Sets a callback for when the socket connects.
|
|
131
|
+
/// </summary>
|
|
104
132
|
internal void setOnConnectHandler(Action _onConnectHandler)
|
|
105
133
|
{
|
|
106
134
|
this.networkingSocketPeerBase.setOnConnectHandler(_onConnectHandler);
|
|
107
135
|
}
|
|
108
136
|
|
|
137
|
+
/// <summary>
|
|
138
|
+
/// Sets a callback for when the socket disconnects.
|
|
139
|
+
/// </summary>
|
|
109
140
|
internal void setOnDisconnectHandler(Action _onDisconnectHandler)
|
|
110
141
|
{
|
|
111
142
|
this.networkingSocketPeerBase.setOnDisconnectHandler(_onDisconnectHandler);
|
|
112
143
|
}
|
|
113
144
|
|
|
145
|
+
/// <summary>
|
|
146
|
+
/// Removes the connection callback.
|
|
147
|
+
/// </summary>
|
|
114
148
|
internal void removeOnConnectHandler(Action _onConnectHandler)
|
|
115
149
|
{
|
|
116
150
|
this.networkingSocketPeerBase.removeOnConnectHandler(_onConnectHandler);
|
|
117
151
|
}
|
|
118
152
|
|
|
153
|
+
/// <summary>
|
|
154
|
+
/// Removes the disconnection callback.
|
|
155
|
+
/// </summary>
|
|
119
156
|
internal void removeOnDisconnectHandler(Action _onDisconnectHandler)
|
|
120
157
|
{
|
|
121
158
|
this.networkingSocketPeerBase.removeOnDisconnectHandler(_onDisconnectHandler);
|
|
122
159
|
}
|
|
123
160
|
|
|
161
|
+
/// <summary>
|
|
162
|
+
/// Connects the socket with a specified callback.
|
|
163
|
+
/// </summary>
|
|
124
164
|
internal void connect(Action _onSocketConnect)
|
|
125
165
|
{
|
|
126
166
|
this.networkingSocketPeerBase.connect(_onSocketConnect);
|
|
127
167
|
}
|
|
128
168
|
|
|
169
|
+
/// <summary>
|
|
170
|
+
/// Disconnects the socket with a specified callback.
|
|
171
|
+
/// </summary>
|
|
129
172
|
internal void disconnect(Action _onSocketDisconnect)
|
|
130
173
|
{
|
|
131
174
|
this.networkingSocketPeerBase.close(_onSocketDisconnect);
|
|
132
175
|
}
|
|
133
176
|
|
|
177
|
+
/// <summary>
|
|
178
|
+
/// Sets the event handler for incoming socket events.
|
|
179
|
+
/// </summary>
|
|
134
180
|
internal void setOnEventHandler(Action<OperationEvent> _onEventHandler)
|
|
135
181
|
{
|
|
136
182
|
this._onEventHandler = _onEventHandler;
|
|
137
183
|
}
|
|
138
184
|
|
|
185
|
+
/// <summary>
|
|
186
|
+
/// Sends an operation request via the socket.
|
|
187
|
+
/// </summary>
|
|
139
188
|
internal override void send(OperationPending operationPending)
|
|
140
189
|
{
|
|
141
190
|
base.send(operationPending);
|
|
@@ -144,11 +193,15 @@
|
|
|
144
193
|
|
|
145
194
|
var authToken = operationPending.getAuthToken();
|
|
146
195
|
var secretKey = operationPending.getSecretKey();
|
|
196
|
+
var gameId = operationPending.getGameId();
|
|
147
197
|
var customTags = operationPending.getCustomTags();
|
|
148
198
|
|
|
149
|
-
this.networkingSocketPeerBase.Send(operationPending.getRequestType(), operationPending.getRequestRole(), operationPending.getOperationRequest(), authToken, secretKey, customTags);
|
|
199
|
+
this.networkingSocketPeerBase.Send(operationPending.getRequestType(), operationPending.getRequestRole(), operationPending.getOperationRequest(), authToken, secretKey, customTags, gameId);
|
|
150
200
|
}
|
|
151
201
|
|
|
202
|
+
/// <summary>
|
|
203
|
+
/// Handles incoming socket events and invokes appropriate handlers.
|
|
204
|
+
/// </summary>
|
|
152
205
|
internal void onEventHandler(GNArray obj, bool isEncrypted)
|
|
153
206
|
{
|
|
154
207
|
var eventCode = obj.getInt(0);
|
|
@@ -160,10 +213,7 @@
|
|
|
160
213
|
|
|
161
214
|
this._onEventHandler?.Invoke(operationEvent);
|
|
162
215
|
|
|
163
|
-
if (!this.serverEventHandlersDict.ContainsKey(eventCode))
|
|
164
|
-
{
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
216
|
+
if (!this.serverEventHandlersDict.ContainsKey(eventCode)) return;
|
|
167
217
|
|
|
168
218
|
var serverEventHandlers = this.serverEventHandlersDict[eventCode];
|
|
169
219
|
|
|
@@ -171,10 +221,12 @@
|
|
|
171
221
|
serverEventHandler.handle(operationEvent);
|
|
172
222
|
}
|
|
173
223
|
|
|
224
|
+
/// <summary>
|
|
225
|
+
/// Processes socket service operations.
|
|
226
|
+
/// </summary>
|
|
174
227
|
public override void service()
|
|
175
228
|
{
|
|
176
229
|
base.service();
|
|
177
|
-
|
|
178
230
|
this.networkingSocketPeerBase?.service();
|
|
179
231
|
}
|
|
180
232
|
|
|
@@ -189,5 +241,4 @@
|
|
|
189
241
|
//}
|
|
190
242
|
|
|
191
243
|
}
|
|
192
|
-
|
|
193
244
|
}
|
|
@@ -2,19 +2,32 @@ namespace XmobiTea.GN.Unity
|
|
|
2
2
|
{
|
|
3
3
|
using XmobiTea.GN.Networking;
|
|
4
4
|
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// The ServiceUpdate class is responsible for updating and handling network services.
|
|
7
|
+
/// </summary>
|
|
5
8
|
internal class ServiceUpdate : UnityEngine.MonoBehaviour
|
|
6
9
|
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// The NetworkingPeer instance used to perform network operations.
|
|
12
|
+
/// </summary>
|
|
7
13
|
internal NetworkingPeer peer;
|
|
8
14
|
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// Handles the logic to update the network service.
|
|
17
|
+
/// </summary>
|
|
9
18
|
private void update()
|
|
10
19
|
{
|
|
20
|
+
// Calls the service() method of the peer object if it is not null.
|
|
11
21
|
this.peer?.service();
|
|
12
22
|
}
|
|
13
23
|
|
|
24
|
+
/// <summary>
|
|
25
|
+
/// Unity's Update method, called once per frame.
|
|
26
|
+
/// </summary>
|
|
14
27
|
void Update()
|
|
15
28
|
{
|
|
29
|
+
// Invokes the custom update() method to handle network logic.
|
|
16
30
|
this.update();
|
|
17
31
|
}
|
|
18
32
|
}
|
|
19
|
-
|
|
20
33
|
}
|