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.
Files changed (112) hide show
  1. package/Editor/GNServerSettingsEditor.cs +42 -322
  2. package/Runtime/Common/GNArray.cs +120 -35
  3. package/Runtime/Common/GNData.cs +19 -6
  4. package/Runtime/Common/GNHashtable.cs +174 -11
  5. package/Runtime/Common/IGNData.cs +11 -2
  6. package/Runtime/Config/GNServerSettings.cs +136 -92
  7. package/Runtime/Constant/Commands.cs +82 -19
  8. package/Runtime/Constant/EnumType/GoogleLoginType.cs +5 -5
  9. package/Runtime/Constant/EnumType/GroupStatus.cs +7 -7
  10. package/Runtime/Constant/EnumType/ItemType.cs +5 -5
  11. package/Runtime/Constant/EnumType/MatchmakingMemberStatus.cs +6 -6
  12. package/Runtime/Constant/EnumType/MatchmakingTicketStatus.cs +2 -2
  13. package/Runtime/Constant/EnumType/OwnerType.cs +3 -2
  14. package/Runtime/Constant/EnumType/PushPlatformType.cs +10 -0
  15. package/Runtime/Constant/EnumType/PushPlatformType.cs.meta +11 -0
  16. package/Runtime/Constant/EnumType/RequestType.cs +1 -0
  17. package/Runtime/Constant/EnumType/StoreReceiveType.cs +13 -0
  18. package/Runtime/Constant/EnumType/StoreReceiveType.cs.meta +11 -0
  19. package/Runtime/Constant/ErrorCode/GNErrorCode.cs +53 -48
  20. package/Runtime/Constant/EventCode.cs +29 -2
  21. package/Runtime/Constant/OperationCode.cs +249 -211
  22. package/Runtime/Constant/ParameterCode/GNParameterCode.cs +610 -466
  23. package/Runtime/Constant/ReturnCode.cs +50 -2
  24. package/Runtime/Entity/DataMember.cs +221 -3
  25. package/Runtime/Entity/GNMetadata.cs +46 -1
  26. package/Runtime/Entity/InvalidMember.cs +24 -5
  27. package/Runtime/Entity/Models/AuthenticateModels.cs +251 -207
  28. package/Runtime/Entity/Models/AuthenticateRequestModels.cs +153 -131
  29. package/Runtime/Entity/Models/AuthenticateResponseModels.cs +61 -51
  30. package/Runtime/Entity/Models/CharacterPlayerModels.cs +985 -849
  31. package/Runtime/Entity/Models/CharacterPlayerRequestModels.cs +957 -885
  32. package/Runtime/Entity/Models/CharacterPlayerResponseModels.cs +165 -150
  33. package/Runtime/Entity/Models/CloudScriptModels.cs +185 -0
  34. package/Runtime/Entity/Models/CloudScriptModels.cs.meta +11 -0
  35. package/Runtime/Entity/Models/CloudScriptRequestModels.cs +134 -0
  36. package/Runtime/Entity/Models/CloudScriptRequestModels.cs.meta +11 -0
  37. package/Runtime/Entity/Models/CloudScriptResponseModels.cs +34 -0
  38. package/Runtime/Entity/Models/CloudScriptResponseModels.cs.meta +11 -0
  39. package/Runtime/Entity/Models/ContentModels.cs +150 -153
  40. package/Runtime/Entity/Models/ContentRequestModels.cs +129 -129
  41. package/Runtime/Entity/Models/ContentResponseModels.cs +24 -24
  42. package/Runtime/Entity/Models/DashboardModels.cs +1684 -1156
  43. package/Runtime/Entity/Models/DashboardRequestModels.cs +220 -147
  44. package/Runtime/Entity/Models/DashboardResponseModels.cs +92 -57
  45. package/Runtime/Entity/Models/GamePlayerModels.cs +1073 -933
  46. package/Runtime/Entity/Models/GamePlayerRequestModels.cs +939 -867
  47. package/Runtime/Entity/Models/GamePlayerResponseModels.cs +162 -147
  48. package/Runtime/Entity/Models/GenericModels.cs +102 -102
  49. package/Runtime/Entity/Models/GroupModels.cs +812 -676
  50. package/Runtime/Entity/Models/GroupRequestModels.cs +741 -669
  51. package/Runtime/Entity/Models/GroupResponseModels.cs +129 -114
  52. package/Runtime/Entity/Models/InventoryModels.cs +667 -558
  53. package/Runtime/Entity/Models/InventoryRequestModels.cs +626 -579
  54. package/Runtime/Entity/Models/InventoryResponseModels.cs +109 -99
  55. package/Runtime/Entity/Models/MasterPlayerModels.cs +1882 -1340
  56. package/Runtime/Entity/Models/MasterPlayerRequestModels.cs +1643 -1253
  57. package/Runtime/Entity/Models/MasterPlayerResponseModels.cs +293 -213
  58. package/Runtime/Entity/Models/MultiplayerModels.cs +293 -223
  59. package/Runtime/Entity/Models/MultiplayerRequestModels.cs +199 -149
  60. package/Runtime/Entity/Models/MultiplayerResponseModels.cs +10 -0
  61. package/Runtime/Entity/Models/StoreInventoryModels.cs +514 -323
  62. package/Runtime/Entity/Models/StoreInventoryRequestModels.cs +236 -165
  63. package/Runtime/Entity/Models/StoreInventoryResponseModels.cs +45 -30
  64. package/Runtime/Entity/OperationEvent.cs +43 -7
  65. package/Runtime/Entity/OperationHelper.cs +18 -2
  66. package/Runtime/Entity/OperationRequest.cs +80 -37
  67. package/Runtime/Entity/OperationResponse.cs +111 -63
  68. package/Runtime/Entity/Request/CustomOperationRequest.cs +53 -2
  69. package/Runtime/Entity/Response/CustomOperationResponse.cs +25 -4
  70. package/Runtime/GNNetwork.cs +333 -21
  71. package/Runtime/GNNetworkApi.cs +25 -13
  72. package/Runtime/GNNetworkAuthenticateApi.cs +531 -98
  73. package/Runtime/GNNetworkCharacterPlayerApi.cs +1587 -762
  74. package/Runtime/GNNetworkCloudScriptApi.cs +181 -0
  75. package/Runtime/GNNetworkCloudScriptApi.cs.meta +11 -0
  76. package/Runtime/GNNetworkContentApi.cs +238 -132
  77. package/Runtime/GNNetworkDashboardApi.cs +278 -117
  78. package/Runtime/GNNetworkGamePlayerApi.cs +1558 -747
  79. package/Runtime/GNNetworkGroupApi.cs +1228 -582
  80. package/Runtime/GNNetworkInventoryApi.cs +1048 -507
  81. package/Runtime/GNNetworkMasterPlayerApi.cs +2586 -1067
  82. package/Runtime/GNNetworkMultiplayerApi.cs +328 -147
  83. package/Runtime/GNNetworkStoreInventoryApi.cs +388 -162
  84. package/Runtime/Helper/CodeHelper.cs +45 -3
  85. package/Runtime/Helper/ConverterService.cs +240 -85
  86. package/Runtime/Logger/GNDebug.cs +46 -3
  87. package/Runtime/Networking/AuthenticateStatus.cs +30 -8
  88. package/Runtime/Networking/Handler/IServerEventHandler.cs +8 -8
  89. package/Runtime/Networking/Handler/OnCharacterPlayerFriendUpdateEventHandler.cs +31 -2
  90. package/Runtime/Networking/Handler/OnCharacterPlayerGroupUpdateEventHandler.cs +24 -3
  91. package/Runtime/Networking/Handler/OnGamePlayerFriendUpdateEventHandler.cs +24 -2
  92. package/Runtime/Networking/Handler/OnGamePlayerGroupUpdateEventHandler.cs +24 -2
  93. package/Runtime/Networking/Handler/OnGroupMemberUpdateEventHandler.cs +21 -2
  94. package/Runtime/Networking/Handler/OnGroupMessageUpdateEventHandler.cs +20 -2
  95. package/Runtime/Networking/Http/HttpPeer.cs +68 -25
  96. package/Runtime/Networking/Http/NetworkingHttpPeerBase.cs +44 -4
  97. package/Runtime/Networking/Http/NetworkingPeerHttpClientRequest.cs +63 -40
  98. package/Runtime/Networking/Http/NetworkingPeerHttpRequest.cs +43 -13
  99. package/Runtime/Networking/Http/NetworkingPeerUnityWebRequest.cs +72 -39
  100. package/Runtime/Networking/IPeer.cs +24 -2
  101. package/Runtime/Networking/NetworkingPeer.cs +64 -10
  102. package/Runtime/Networking/NetworkingPeerAPI.cs +20 -21
  103. package/Runtime/Networking/OperationPending.cs +79 -15
  104. package/Runtime/Networking/PeerBase.cs +86 -23
  105. package/Runtime/Networking/Socket/NetworkingPeerSocketV2.cs +57 -18
  106. package/Runtime/Networking/Socket/NetworkingPeerSocketV3.cs +70 -10
  107. package/Runtime/Networking/Socket/NetworkingSocketPeerBase.cs +165 -23
  108. package/Runtime/Networking/Socket/SocketPeer.cs +63 -12
  109. package/Runtime/Unity/ServiceCoroutine.cs +10 -0
  110. package/Runtime/Unity/ServiceCoroutine.cs.meta +11 -0
  111. package/Runtime/Unity/ServiceUpdate.cs +14 -1
  112. package/package.json +1 -1
@@ -1,21 +1,31 @@
1
1
  namespace XmobiTea.GN.Networking.Socket
2
2
  {
3
- using System;
3
+ #if UNITY_USING_BEST_HTTP
4
4
 
5
5
  using BestHTTP.SocketIO3;
6
- using XmobiTea.GN.Entity;
6
+ using System;
7
+ using XmobiTea.GN.Common;
7
8
  using XmobiTea.GN.Constant;
8
- using XmobiTea.MsgPack;
9
+ using XmobiTea.GN.Entity;
9
10
  using XmobiTea.GN.Logger;
10
- using XmobiTea.GN.Common;
11
+ using XmobiTea.MsgPack;
11
12
 
13
+ /// <summary>
14
+ /// Handles socket networking using BestHTTP Socket.IO v3.
15
+ /// </summary>
12
16
  internal class NetworkingPeerSocketV3 : NetworkingSocketPeerBase
13
17
  {
14
18
  private SocketManager socketManager;
15
19
  private bool isConnected;
16
20
 
21
+ /// <summary>
22
+ /// Gets whether the WebSocket connection is open.
23
+ /// </summary>
17
24
  internal override bool isWsConnected => this.socketManager != null ? this.socketManager.State == SocketManager.States.Open : false;
18
25
 
26
+ /// <summary>
27
+ /// Sends an authentication request via the socket.
28
+ /// </summary>
19
29
  internal override void sendRequestAuthSocket()
20
30
  {
21
31
  base.sendRequestAuthSocket();
@@ -24,6 +34,9 @@ namespace XmobiTea.GN.Networking.Socket
24
34
  this.socketManager.Socket.Emit(Commands.RequestAuthTokenCmd, GNNetwork.getAuthenticateStatus().getAuthToken());
25
35
  }
26
36
 
37
+ /// <summary>
38
+ /// Reinitializes the socket with a new configuration.
39
+ /// </summary>
27
40
  internal override void reInitNewSocket()
28
41
  {
29
42
  base.reInitNewSocket();
@@ -52,11 +65,18 @@ namespace XmobiTea.GN.Networking.Socket
52
65
  }
53
66
  }
54
67
 
68
+ /// <summary>
69
+ /// Handles socket error events.
70
+ /// </summary>
55
71
  private void onError()
56
72
  {
57
73
  GNDebug.log("[GN Socket RECV] Handle Error ");
58
74
  }
59
75
 
76
+ /// <summary>
77
+ /// Handles MsgPack response messages.
78
+ /// </summary>
79
+ /// <param name="responseData">The response data in byte array format.</param>
60
80
  private void onResponseMsgPack(byte[] responseData)
61
81
  {
62
82
  lock (this.messageLstLock)
@@ -65,6 +85,10 @@ namespace XmobiTea.GN.Networking.Socket
65
85
  }
66
86
  }
67
87
 
88
+ /// <summary>
89
+ /// Handles MsgPack event messages.
90
+ /// </summary>
91
+ /// <param name="eventData">The event data in byte array format.</param>
68
92
  private void onEventMsgPack(byte[] eventData)
69
93
  {
70
94
  lock (this.messageLstLock)
@@ -73,6 +97,10 @@ namespace XmobiTea.GN.Networking.Socket
73
97
  }
74
98
  }
75
99
 
100
+ /// <summary>
101
+ /// Handles JSON response messages.
102
+ /// </summary>
103
+ /// <param name="responseData">The response data as an object array.</param>
76
104
  private void onResponseJson(object[] responseData)
77
105
  {
78
106
  lock (this.messageLstLock)
@@ -81,6 +109,10 @@ namespace XmobiTea.GN.Networking.Socket
81
109
  }
82
110
  }
83
111
 
112
+ /// <summary>
113
+ /// Handles JSON event messages.
114
+ /// </summary>
115
+ /// <param name="eventData">The event data as an object array.</param>
84
116
  private void onEventJson(object[] eventData)
85
117
  {
86
118
  lock (this.messageLstLock)
@@ -89,6 +121,9 @@ namespace XmobiTea.GN.Networking.Socket
89
121
  }
90
122
  }
91
123
 
124
+ /// <summary>
125
+ /// Handles socket disconnection events.
126
+ /// </summary>
92
127
  private void onDisconnect()
93
128
  {
94
129
  GNDebug.log("[GN Socket RECV] HandleClose ");
@@ -98,6 +133,9 @@ namespace XmobiTea.GN.Networking.Socket
98
133
  this.onDisconnectHandler();
99
134
  }
100
135
 
136
+ /// <summary>
137
+ /// Handles socket connection events.
138
+ /// </summary>
101
139
  private void onConnect()
102
140
  {
103
141
  GNDebug.log("[GN Socket RECV] HandleOpen " + this.socketManager.Socket.Id);
@@ -107,18 +145,33 @@ namespace XmobiTea.GN.Networking.Socket
107
145
  this.onConnectHandler();
108
146
  }
109
147
 
148
+ /// <summary>
149
+ /// Initializes the socket with the given configuration.
150
+ /// </summary>
151
+ /// <param name="url">The server URL.</param>
152
+ /// <param name="reconnectDelay">Delay in seconds before attempting to reconnect.</param>
153
+ /// <param name="pingInterval">Ping interval in seconds.</param>
154
+ /// <param name="pingTimeout">Ping timeout in seconds.</param>
110
155
  internal override void init(string url, int reconnectDelay, float pingInterval, float pingTimeout)
111
156
  {
112
157
  base.init(url, reconnectDelay, pingInterval, pingTimeout);
113
158
  }
114
159
 
115
- protected override void emit(RequestType requestType, RequestRole requestRole, OperationRequest operationRequest, string authToken, string secretKey, GNHashtable customTags)
160
+ /// <summary>
161
+ /// Emits a request via the socket.
162
+ /// </summary>
163
+ /// <param name="requestType">The type of request to emit.</param>
164
+ /// <param name="requestRole">The role associated with the request.</param>
165
+ /// <param name="operationRequest">The operation request data.</param>
166
+ /// <param name="authToken">Authentication token, if available.</param>
167
+ /// <param name="secretKey">Secret key, if available.</param>
168
+ /// <param name="customTags">Custom tags for the request.</param>
169
+ protected override void emit(RequestType requestType, RequestRole requestRole, OperationRequest operationRequest, string authToken, string secretKey, GNHashtable customTags, string gameId)
116
170
  {
117
- base.emit(requestType, requestRole, operationRequest, authToken, secretKey, customTags);
171
+ base.emit(requestType, requestRole, operationRequest, authToken, secretKey, customTags, gameId);
118
172
 
119
173
  if (this.socketManager == null || this.socketManager.Socket == null)
120
174
  {
121
- // callback here
122
175
  return;
123
176
  }
124
177
 
@@ -132,6 +185,10 @@ namespace XmobiTea.GN.Networking.Socket
132
185
  this.socketManager.Socket.Emit(Commands.RequestCmd_Json, dataSend);
133
186
  }
134
187
 
188
+ /// <summary>
189
+ /// Closes the socket connection.
190
+ /// </summary>
191
+ /// <param name="_onSocketDisconnect">Callback for when the socket is disconnected.</param>
135
192
  internal override void close(Action _onSocketDisconnect)
136
193
  {
137
194
  base.close(_onSocketDisconnect);
@@ -149,9 +206,13 @@ namespace XmobiTea.GN.Networking.Socket
149
206
 
150
207
  GNDebug.log("[GN Socket] Disconnecting via SocketIOv3 BestHTTP 2");
151
208
 
152
- onDisconnectHandler();
209
+ this.onDisconnectHandler();
153
210
  }
154
211
 
212
+ /// <summary>
213
+ /// Opens a socket connection.
214
+ /// </summary>
215
+ /// <param name="_onSocketConnect">Callback for when the socket is connected.</param>
155
216
  internal override void connect(Action _onSocketConnect)
156
217
  {
157
218
  base.connect(_onSocketConnect);
@@ -159,7 +220,6 @@ namespace XmobiTea.GN.Networking.Socket
159
220
  if (this.isConnected)
160
221
  {
161
222
  GNDebug.log("[GN Socket] Reconnecting");
162
-
163
223
  return;
164
224
  }
165
225
 
@@ -169,7 +229,7 @@ namespace XmobiTea.GN.Networking.Socket
169
229
 
170
230
  if (this.socketManager != null) this.socketManager.Open();
171
231
  }
172
-
173
232
  }
174
233
 
234
+ #endif
175
235
  }
@@ -9,18 +9,42 @@ namespace XmobiTea.GN.Networking.Socket
9
9
  using XmobiTea.GN.Logger;
10
10
  using XmobiTea.MsgPack;
11
11
 
12
+ /// <summary>
13
+ /// Represents a socket packet containing data and encryption information.
14
+ /// </summary>
12
15
  public class SocketPacket
13
16
  {
17
+ /// <summary>
18
+ /// Gets the byte array of the packet data.
19
+ /// </summary>
14
20
  public byte[] byteArr { get; private set; }
21
+
22
+ /// <summary>
23
+ /// Indicates whether the packet is encrypted.
24
+ /// </summary>
15
25
  public bool encrypted { get; private set; }
26
+
27
+ /// <summary>
28
+ /// Gets the object data of the packet.
29
+ /// </summary>
16
30
  public object obj { get; private set; }
17
31
 
32
+ /// <summary>
33
+ /// Initializes a new instance of the <see cref="SocketPacket"/> class with byte array data.
34
+ /// </summary>
35
+ /// <param name="byteArr">The byte array of the packet.</param>
36
+ /// <param name="encrypted">Indicates whether the packet is encrypted.</param>
18
37
  public SocketPacket(byte[] byteArr, bool encrypted)
19
38
  {
20
39
  this.byteArr = byteArr;
21
40
  this.encrypted = encrypted;
22
41
  }
23
42
 
43
+ /// <summary>
44
+ /// Initializes a new instance of the <see cref="SocketPacket"/> class with object data.
45
+ /// </summary>
46
+ /// <param name="obj">The object data of the packet.</param>
47
+ /// <param name="encrypted">Indicates whether the packet is encrypted.</param>
24
48
  public SocketPacket(object obj, bool encrypted)
25
49
  {
26
50
  this.obj = obj;
@@ -28,51 +52,92 @@ namespace XmobiTea.GN.Networking.Socket
28
52
  }
29
53
  }
30
54
 
55
+ /// <summary>
56
+ /// Base class for managing socket peer connections.
57
+ /// </summary>
31
58
  public abstract class NetworkingSocketPeerBase
32
59
  {
33
60
  #region Public Properties
34
61
 
62
+ /// <summary>
63
+ /// The delay between reconnection attempts, in milliseconds.
64
+ /// </summary>
35
65
  protected internal int reconnectDelay;
66
+
67
+ /// <summary>
68
+ /// The interval for ping messages, in seconds.
69
+ /// </summary>
36
70
  protected internal float pingInterval;
71
+
72
+ /// <summary>
73
+ /// The timeout for ping messages, in seconds.
74
+ /// </summary>
37
75
  protected internal float pingTimeout;
38
76
 
77
+ /// <summary>
78
+ /// Gets or sets the client ID for the connection.
79
+ /// </summary>
39
80
  internal string clientId { get; set; }
81
+
82
+ /// <summary>
83
+ /// Gets whether the WebSocket connection is open.
84
+ /// </summary>
40
85
  internal virtual bool isWsConnected { get; private set; }
41
86
 
87
+ /// <summary>
88
+ /// Lock object for message lists.
89
+ /// </summary>
42
90
  protected internal object messageLstLock;
91
+
92
+ /// <summary>
93
+ /// List of response packets.
94
+ /// </summary>
43
95
  protected internal List<SocketPacket> responsePacketLst;
96
+
97
+ /// <summary>
98
+ /// List of event packets.
99
+ /// </summary>
44
100
  protected internal List<SocketPacket> eventPacketLst;
45
101
 
46
102
  #endregion
47
103
 
48
104
  #region Private Properties
49
105
 
106
+ /// <summary>
107
+ /// The server URL.
108
+ /// </summary>
50
109
  protected string url;
51
110
 
52
111
  private Action<GNArray, bool> _onEventHandler;
53
112
  private Action<GNArray, bool> _onResponseHandler;
54
-
55
113
  private Action _onSocketConnect;
56
114
  private Action _onSocketDisconnect;
57
-
58
115
  private Action _onConnectHandler;
59
116
  private Action _onDisconnectHandler;
60
117
 
61
118
  #endregion
62
119
 
120
+ /// <summary>
121
+ /// Initializes the socket peer with the specified settings.
122
+ /// </summary>
123
+ /// <param name="url">The server URL.</param>
124
+ /// <param name="reconnectDelay">Delay in milliseconds before reconnect attempts.</param>
125
+ /// <param name="pingInterval">Ping interval in seconds.</param>
126
+ /// <param name="pingTimeout">Ping timeout in seconds.</param>
63
127
  internal virtual void init(string url, int reconnectDelay, float pingInterval, float pingTimeout)
64
128
  {
65
129
  this.url = url;
66
-
67
130
  this.reconnectDelay = reconnectDelay;
68
131
  this.pingInterval = pingInterval;
69
132
  this.pingTimeout = pingTimeout;
70
133
  }
71
134
 
135
+ /// <summary>
136
+ /// Constructor for initializing the NetworkingSocketPeerBase class.
137
+ /// </summary>
72
138
  public NetworkingSocketPeerBase()
73
139
  {
74
140
  this.clientId = string.Empty;
75
-
76
141
  this.messageLstLock = new object();
77
142
  this.responsePacketLst = new List<SocketPacket>();
78
143
  this.eventPacketLst = new List<SocketPacket>();
@@ -80,59 +145,98 @@ namespace XmobiTea.GN.Networking.Socket
80
145
 
81
146
  #region Public Interface
82
147
 
148
+ /// <summary>
149
+ /// Connects to the socket server.
150
+ /// </summary>
151
+ /// <param name="_onSocketConnect">Callback invoked upon successful connection.</param>
83
152
  internal virtual void connect(Action _onSocketConnect)
84
153
  {
85
154
  this._onSocketConnect = _onSocketConnect;
86
155
  }
87
156
 
157
+ /// <summary>
158
+ /// Closes the socket connection.
159
+ /// </summary>
160
+ /// <param name="_onSocketDisconnect">Callback invoked upon disconnection.</param>
88
161
  internal virtual void close(Action _onSocketDisconnect)
89
162
  {
90
163
  this._onSocketDisconnect = _onSocketDisconnect;
91
164
  }
92
165
 
93
- internal virtual void sendRequestAuthSocket()
166
+ /// <summary>
167
+ /// Sends an authentication request via the socket.
168
+ /// </summary>
169
+ internal virtual void sendRequestAuthSocket() { }
170
+
171
+ /// <summary>
172
+ /// Sends a request via the socket.
173
+ /// </summary>
174
+ /// <param name="requestType">The type of the request.</param>
175
+ /// <param name="requestRole">The role of the request.</param>
176
+ /// <param name="operationRequest">The operation request object.</param>
177
+ /// <param name="authToken">Authentication token, if applicable.</param>
178
+ /// <param name="secretKey">Secret key, if applicable.</param>
179
+ /// <param name="customTags">Custom tags for the request.</param>
180
+ internal void Send(RequestType requestType, RequestRole requestRole, OperationRequest operationRequest, string authToken, string secretKey, GNHashtable customTags, string gameId)
94
181
  {
95
-
182
+ this.emit(requestType, requestRole, operationRequest, authToken, secretKey, customTags, gameId);
96
183
  }
97
184
 
98
- internal void Send(RequestType requestType, RequestRole requestRole, OperationRequest operationRequest, string authToken, string secretKey, GNHashtable customTags)
99
- {
100
- this.emit(requestType, requestRole, operationRequest, authToken, secretKey, customTags);
101
- }
102
-
103
- protected virtual void emit(RequestType requestType, RequestRole requestRole, OperationRequest operationRequest, string authToken, string secretKey, GNHashtable customTags) { }
185
+ /// <summary>
186
+ /// Emits a request to the socket.
187
+ /// </summary>
188
+ protected virtual void emit(RequestType requestType, RequestRole requestRole, OperationRequest operationRequest, string authToken, string secretKey, GNHashtable customTags, string gameId) { }
104
189
 
105
190
  #endregion
106
191
 
107
192
  #region Private Methods
108
193
 
109
- internal virtual void reInitNewSocket()
110
- {
111
-
112
- }
194
+ /// <summary>
195
+ /// Reinitializes the socket connection with a new configuration.
196
+ /// </summary>
197
+ internal virtual void reInitNewSocket() { }
113
198
 
199
+ /// <summary>
200
+ /// Sets the callback to be invoked when the socket connects.
201
+ /// </summary>
202
+ /// <param name="_onConnectHandler">The callback action.</param>
114
203
  internal void setOnConnectHandler(Action _onConnectHandler)
115
204
  {
116
205
  this._onConnectHandler -= _onConnectHandler;
117
206
  this._onConnectHandler += _onConnectHandler;
118
207
  }
119
208
 
209
+ /// <summary>
210
+ /// Sets the callback to be invoked when the socket disconnects.
211
+ /// </summary>
212
+ /// <param name="_onDisconnectHandler">The callback action.</param>
120
213
  internal void setOnDisconnectHandler(Action _onDisconnectHandler)
121
214
  {
122
215
  this._onDisconnectHandler -= _onDisconnectHandler;
123
216
  this._onDisconnectHandler += _onDisconnectHandler;
124
217
  }
125
218
 
219
+ /// <summary>
220
+ /// Removes the specified callback for socket connection events.
221
+ /// </summary>
222
+ /// <param name="_onConnectHandler">The callback action to remove.</param>
126
223
  internal void removeOnConnectHandler(Action _onConnectHandler)
127
224
  {
128
225
  this._onConnectHandler -= _onConnectHandler;
129
226
  }
130
227
 
228
+ /// <summary>
229
+ /// Removes the specified callback for socket disconnection events.
230
+ /// </summary>
231
+ /// <param name="_onDisconnectHandler">The callback action to remove.</param>
131
232
  internal void removeOnDisconnectHandler(Action _onDisconnectHandler)
132
233
  {
133
234
  this._onDisconnectHandler -= _onDisconnectHandler;
134
235
  }
135
236
 
237
+ /// <summary>
238
+ /// Invokes the connection handler and sends an authentication request if applicable.
239
+ /// </summary>
136
240
  internal void onConnectHandler()
137
241
  {
138
242
  this._onConnectHandler?.Invoke();
@@ -147,34 +251,58 @@ namespace XmobiTea.GN.Networking.Socket
147
251
  this._onSocketConnect = null;
148
252
  }
149
253
 
254
+ /// <summary>
255
+ /// Invokes the disconnection handler and cleans up associated resources.
256
+ /// </summary>
150
257
  internal void onDisconnectHandler()
151
258
  {
152
259
  this._onDisconnectHandler?.Invoke();
153
-
154
260
  this._onSocketDisconnect?.Invoke();
155
261
  this._onSocketDisconnect = null;
156
262
  }
157
263
 
264
+ /// <summary>
265
+ /// Sets the handler for processing socket events.
266
+ /// </summary>
267
+ /// <param name="_onEventHandler">The event handler action.</param>
158
268
  internal void setOnEventHandler(Action<GNArray, bool> _onEventHandler)
159
269
  {
160
270
  this._onEventHandler = _onEventHandler;
161
271
  }
162
272
 
273
+ /// <summary>
274
+ /// Invokes the event handler with the specified data and encryption status.
275
+ /// </summary>
276
+ /// <param name="obj">The event data.</param>
277
+ /// <param name="isEncrypted">Indicates whether the data is encrypted.</param>
163
278
  internal void onEventHandler(GNArray obj, bool isEncrypted)
164
279
  {
165
280
  this._onEventHandler?.Invoke(obj, isEncrypted);
166
281
  }
167
282
 
283
+ /// <summary>
284
+ /// Sets the handler for processing socket responses.
285
+ /// </summary>
286
+ /// <param name="_onResponseHandler">The response handler action.</param>
168
287
  internal void setOnResponseHandler(Action<GNArray, bool> _onResponseHandler)
169
288
  {
170
289
  this._onResponseHandler = _onResponseHandler;
171
290
  }
172
291
 
292
+ /// <summary>
293
+ /// Invokes the response handler with the specified data and encryption status.
294
+ /// </summary>
295
+ /// <param name="obj">The response data.</param>
296
+ /// <param name="isEncrypted">Indicates whether the data is encrypted.</param>
173
297
  internal void onResponseHandler(GNArray obj, bool isEncrypted)
174
298
  {
175
299
  this._onResponseHandler?.Invoke(obj, isEncrypted);
176
300
  }
177
-
301
+ /// <summary>
302
+ /// Converts an array of key-value pairs to a dictionary.
303
+ /// </summary>
304
+ /// <param name="keyValuePairs">The array of key-value pairs to convert.</param>
305
+ /// <returns>A dictionary representing the key-value pairs.</returns>
178
306
  internal static System.Collections.IDictionary fromMsgKeyValuePairs(KeyValuePair<object, object>[] keyValuePairs)
179
307
  {
180
308
  var answer = new Dictionary<object, object>();
@@ -203,6 +331,11 @@ namespace XmobiTea.GN.Networking.Socket
203
331
  return answer;
204
332
  }
205
333
 
334
+ /// <summary>
335
+ /// Converts an array of objects to a list.
336
+ /// </summary>
337
+ /// <param name="objects">The array of objects to convert.</param>
338
+ /// <returns>A list representing the objects.</returns>
206
339
  internal static System.Collections.IList fromMsgList(object[] objects)
207
340
  {
208
341
  var answer = new List<object>();
@@ -228,15 +361,24 @@ namespace XmobiTea.GN.Networking.Socket
228
361
  return answer;
229
362
  }
230
363
 
364
+ /// <summary>
365
+ /// Converts a JSON object to a list.
366
+ /// </summary>
367
+ /// <param name="objects">The JSON object to convert.</param>
368
+ /// <returns>A list representing the JSON object.</returns>
231
369
  internal static System.Collections.IList fromJsonList(object objects)
232
370
  {
233
371
  return (System.Collections.IList)objects;
234
372
  }
235
373
 
374
+ /// <summary>
375
+ /// Processes incoming response and event packets.
376
+ /// </summary>
236
377
  internal void service()
237
378
  {
238
379
  lock (this.messageLstLock)
239
380
  {
381
+ // Process response packets
240
382
  if (this.responsePacketLst.Count > 0)
241
383
  {
242
384
  for (var i = 0; i < this.responsePacketLst.Count; i++)
@@ -254,7 +396,7 @@ namespace XmobiTea.GN.Networking.Socket
254
396
  var gnArray = new GNArray.Builder()
255
397
  .addAll(NetworkingSocketPeerBase.fromMsgList(iList))
256
398
  .build();
257
- onResponseHandler(gnArray, responsePacket.encrypted);
399
+ this.onResponseHandler(gnArray, responsePacket.encrypted);
258
400
  }
259
401
  catch (Exception ex)
260
402
  {
@@ -270,7 +412,7 @@ namespace XmobiTea.GN.Networking.Socket
270
412
  var gnArray = new GNArray.Builder()
271
413
  .addAll(NetworkingSocketPeerBase.fromJsonList(iList))
272
414
  .build();
273
- onResponseHandler(gnArray, responsePacket.encrypted);
415
+ this.onResponseHandler(gnArray, responsePacket.encrypted);
274
416
  }
275
417
  catch (Exception ex)
276
418
  {
@@ -282,6 +424,7 @@ namespace XmobiTea.GN.Networking.Socket
282
424
  this.responsePacketLst.Clear();
283
425
  }
284
426
 
427
+ // Process event packets
285
428
  if (this.eventPacketLst.Count > 0)
286
429
  {
287
430
  for (var i = 0; i < this.eventPacketLst.Count; i++)
@@ -299,7 +442,7 @@ namespace XmobiTea.GN.Networking.Socket
299
442
  var gnArray = new GNArray.Builder()
300
443
  .addAll(NetworkingSocketPeerBase.fromMsgList(iList))
301
444
  .build();
302
- onEventHandler(gnArray, eventPacket.encrypted);
445
+ this.onEventHandler(gnArray, eventPacket.encrypted);
303
446
  }
304
447
  catch (Exception ex)
305
448
  {
@@ -315,7 +458,7 @@ namespace XmobiTea.GN.Networking.Socket
315
458
  var gnArray = new GNArray.Builder()
316
459
  .addAll(NetworkingSocketPeerBase.fromJsonList(iList))
317
460
  .build();
318
- onEventHandler(gnArray, eventPacket.encrypted);
461
+ this.onEventHandler(gnArray, eventPacket.encrypted);
319
462
  }
320
463
  catch (Exception ex)
321
464
  {
@@ -331,5 +474,4 @@ namespace XmobiTea.GN.Networking.Socket
331
474
 
332
475
  #endregion
333
476
  }
334
-
335
477
  }