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
@@ -5,7 +5,7 @@
5
5
  using System.Text;
6
6
 
7
7
  /// <summary>
8
- /// The GNData dictionary, it store Dictionary can be use to request or response
8
+ /// A hashtable implementation for GNData, supporting serialization and custom key-value storage.
9
9
  /// </summary>
10
10
  public class GNHashtable : GNData
11
11
  {
@@ -13,6 +13,12 @@
13
13
  {
14
14
  private IDictionary<string, object> dict;
15
15
 
16
+ /// <summary>
17
+ /// Adds a key-value pair to the internal dictionary.
18
+ /// </summary>
19
+ /// <param name="key">The key for the entry, must be a string.</param>
20
+ /// <param name="value">The value for the entry.</param>
21
+ /// <returns>The current Builder instance.</returns>
16
22
  public Builder add(string key, object value)
17
23
  {
18
24
  this.dict[key] = value;
@@ -20,6 +26,11 @@
20
26
  return this;
21
27
  }
22
28
 
29
+ /// <summary>
30
+ /// Adds all key-value pairs from an existing dictionary to the internal dictionary.
31
+ /// </summary>
32
+ /// <param name="dict">The dictionary containing key-value pairs to add.</param>
33
+ /// <returns>The current Builder instance.</returns>
23
34
  public Builder addAll(System.Collections.IDictionary dict)
24
35
  {
25
36
  var keys = dict.Keys;
@@ -30,23 +41,29 @@
30
41
  this.add(keyStr, dict[key]);
31
42
  }
32
43
  }
33
-
34
44
  return this;
35
45
  }
36
46
 
47
+ /// <summary>
48
+ /// Constructs a new GNHashtable instance using the current key-value pairs.
49
+ /// </summary>
50
+ /// <returns>A GNHashtable containing the added key-value pairs.</returns>
37
51
  public GNHashtable build()
38
52
  {
39
- var awnser = new GNHashtable();
53
+ var answer = new GNHashtable();
40
54
 
41
55
  var keys = this.dict.Keys;
42
56
  foreach (var key in keys)
43
57
  {
44
- awnser.add(key, this.dict[key]);
58
+ answer.add(key, this.dict[key]);
45
59
  }
46
60
 
47
- return awnser;
61
+ return answer;
48
62
  }
49
63
 
64
+ /// <summary>
65
+ /// Initializes a new instance of the Builder class.
66
+ /// </summary>
50
67
  public Builder()
51
68
  {
52
69
  this.dict = new Dictionary<string, object>();
@@ -55,46 +72,97 @@
55
72
 
56
73
  private IDictionary<string, object> dict;
57
74
 
75
+ /// <summary>
76
+ /// Initializes a new instance of the GNHashtable class.
77
+ /// </summary>
58
78
  public GNHashtable()
59
79
  {
60
80
  this.dict = new Dictionary<string, object>();
61
81
  }
62
82
 
83
+ /// <summary>
84
+ /// Adds or updates a key-value pair in the hashtable.
85
+ /// </summary>
86
+ /// <param name="key">The key to add or update.</param>
87
+ /// <param name="value">The value associated with the key.</param>
63
88
  public void add(string key, object value)
64
89
  {
65
90
  this.dict[key] = GNData.createUseDataFromOriginData(value);
66
91
  }
67
92
 
93
+ /// <summary>
94
+ /// Gets or sets the value associated with the specified key.
95
+ /// </summary>
96
+ /// <param name="key">The key to get or set.</param>
97
+ /// <returns>The value associated with the key.</returns>
98
+ public object this[string key]
99
+ {
100
+ get => this.getObject(key);
101
+ set => this.add(key, value);
102
+ }
103
+
104
+ /// <summary>
105
+ /// Gets a collection of all values in the hashtable.
106
+ /// </summary>
107
+ /// <returns>A collection of all values in the hashtable.</returns>
68
108
  public ICollection<object> values()
69
109
  {
70
110
  return this.dict.Values;
71
111
  }
72
112
 
113
+ /// <summary>
114
+ /// Gets a collection of all keys in the hashtable.
115
+ /// </summary>
116
+ /// <returns>A collection of all keys in the hashtable.</returns>
73
117
  public ICollection<string> keys()
74
118
  {
75
119
  return this.dict.Keys;
76
120
  }
77
121
 
122
+ /// <summary>
123
+ /// Determines whether the hashtable contains the specified key.
124
+ /// </summary>
125
+ /// <param name="key">The key to locate.</param>
126
+ /// <returns>true if the hashtable contains the key; otherwise, false.</returns>
78
127
  public bool containsKey(string key)
79
128
  {
80
129
  return this.dict.ContainsKey(key);
81
130
  }
82
131
 
132
+ /// <summary>
133
+ /// Removes all key-value pairs from the hashtable.
134
+ /// </summary>
83
135
  public void clear()
84
136
  {
85
137
  this.dict.Clear();
86
138
  }
87
139
 
140
+ /// <summary>
141
+ /// Removes the value associated with the specified key.
142
+ /// </summary>
143
+ /// <param name="key">The key of the value to remove.</param>
144
+ /// <returns>true if the value was successfully removed; otherwise, false.</returns>
88
145
  public bool remove(string key)
89
146
  {
90
147
  return this.dict.Remove(key);
91
148
  }
92
149
 
150
+ /// <summary>
151
+ /// Gets the number of key-value pairs in the hashtable.
152
+ /// </summary>
153
+ /// <returns>The number of key-value pairs in the hashtable.</returns>
93
154
  public int count()
94
155
  {
95
156
  return this.dict.Count;
96
157
  }
97
158
 
159
+ /// <summary>
160
+ /// Retrieves the value associated with the specified key, or a default value if the key does not exist.
161
+ /// </summary>
162
+ /// <typeparam name="T">The expected type of the value.</typeparam>
163
+ /// <param name="k">The key to locate.</param>
164
+ /// <param name="defaultValue">The default value to return if the key is not found.</param>
165
+ /// <returns>The value associated with the key, or the default value if the key is not found.</returns>
98
166
  protected object get<T>(string k, T defaultValue = default(T))
99
167
  {
100
168
  if (this.dict.ContainsKey(k))
@@ -114,56 +182,122 @@
114
182
  return defaultValue;
115
183
  }
116
184
 
185
+ /// <summary>
186
+ /// Retrieves a byte value from the hashtable for the specified key.
187
+ /// </summary>
188
+ /// <param name="k">The key to lookup in the hashtable.</param>
189
+ /// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
190
+ /// <returns>The byte value associated with the key or the default value.</returns>
117
191
  public byte getByte(string k, byte defaultValue = 0)
118
192
  {
119
193
  return Convert.ToByte(this.get(k, defaultValue));
120
194
  }
121
195
 
196
+ /// <summary>
197
+ /// Retrieves a signed byte (sbyte) value from the hashtable for the specified key.
198
+ /// </summary>
199
+ /// <param name="k">The key to lookup in the hashtable.</param>
200
+ /// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
201
+ /// <returns>The sbyte value associated with the key or the default value.</returns>
122
202
  public sbyte getSByte(string k, sbyte defaultValue = 0)
123
203
  {
124
204
  return Convert.ToSByte(this.get(k, defaultValue));
125
205
  }
126
206
 
207
+ /// <summary>
208
+ /// Retrieves a short value from the hashtable for the specified key.
209
+ /// </summary>
210
+ /// <param name="k">The key to lookup in the hashtable.</param>
211
+ /// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
212
+ /// <returns>The short value associated with the key or the default value.</returns>
127
213
  public short getShort(string k, short defaultValue = 0)
128
214
  {
129
215
  return Convert.ToInt16(this.get(k, defaultValue));
130
216
  }
131
217
 
218
+ /// <summary>
219
+ /// Retrieves an integer value from the hashtable for the specified key.
220
+ /// </summary>
221
+ /// <param name="k">The key to lookup in the hashtable.</param>
222
+ /// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
223
+ /// <returns>The integer value associated with the key or the default value.</returns>
132
224
  public int getInt(string k, int defaultValue = 0)
133
225
  {
134
226
  return Convert.ToInt32(this.get(k, defaultValue));
135
227
  }
136
228
 
229
+ /// <summary>
230
+ /// Retrieves a float value from the hashtable for the specified key.
231
+ /// </summary>
232
+ /// <param name="k">The key to lookup in the hashtable.</param>
233
+ /// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
234
+ /// <returns>The float value associated with the key or the default value.</returns>
137
235
  public float getFloat(string k, float defaultValue = 0)
138
236
  {
139
237
  return Convert.ToSingle(this.get(k, defaultValue));
140
238
  }
141
239
 
240
+ /// <summary>
241
+ /// Retrieves a long value from the hashtable for the specified key.
242
+ /// </summary>
243
+ /// <param name="k">The key to lookup in the hashtable.</param>
244
+ /// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
245
+ /// <returns>The long value associated with the key or the default value.</returns>
142
246
  public long getLong(string k, long defaultValue = 0)
143
247
  {
144
248
  return Convert.ToInt64(this.get(k, defaultValue));
145
249
  }
146
250
 
251
+ /// <summary>
252
+ /// Retrieves a double value from the hashtable for the specified key.
253
+ /// </summary>
254
+ /// <param name="k">The key to lookup in the hashtable.</param>
255
+ /// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
256
+ /// <returns>The double value associated with the key or the default value.</returns>
147
257
  public double getDouble(string k, double defaultValue = 0)
148
258
  {
149
259
  return Convert.ToDouble(this.get(k, defaultValue));
150
260
  }
151
261
 
262
+ /// <summary>
263
+ /// Retrieves a boolean value from the hashtable for the specified key.
264
+ /// </summary>
265
+ /// <param name="k">The key to lookup in the hashtable.</param>
266
+ /// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
267
+ /// <returns>The boolean value associated with the key or the default value.</returns>
152
268
  public bool getBool(string k, bool defaultValue = false)
153
269
  {
154
270
  return Convert.ToBoolean(this.get(k, defaultValue));
155
271
  }
156
272
 
273
+ /// <summary>
274
+ /// Retrieves a string value from the hashtable for the specified key.
275
+ /// </summary>
276
+ /// <param name="k">The key to lookup in the hashtable.</param>
277
+ /// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
278
+ /// <returns>The string value associated with the key or the default value.</returns>
157
279
  public string getString(string k, string defaultValue = null)
158
280
  {
159
281
  return Convert.ToString(this.get(k, defaultValue));
160
282
  }
161
283
 
284
+ /// <summary>
285
+ /// Retrieves a raw object from the hashtable for the specified key.
286
+ /// </summary>
287
+ /// <param name="k">The key to lookup in the hashtable.</param>
288
+ /// <param name="defaultValue">The default value to return if the key does not exist or the value cannot be converted.</param>
289
+ /// <returns>The object associated with the key or the default value.</returns>
162
290
  public object getObject(string k, object defaultValue = null)
163
291
  {
164
292
  return this.get(k, defaultValue);
165
293
  }
166
294
 
295
+ /// <summary>
296
+ /// Retrieves an array of type <typeparamref name="T"/> from the hashtable for the specified key.
297
+ /// </summary>
298
+ /// <param name="k">The key to lookup in the hashtable.</param>
299
+ /// <param name="defaultValue">The default value to return if the key does not exist or cannot be converted.</param>
300
+ /// <returns>An array of type <typeparamref name="T"/> or the default value.</returns>
167
301
  public T[] getArray<T>(string k, T[] defaultValue = null)
168
302
  {
169
303
  var value0 = this.getGNArray(k);
@@ -175,6 +309,12 @@
175
309
  return defaultValue;
176
310
  }
177
311
 
312
+ /// <summary>
313
+ /// Retrieves a list of type <typeparamref name="T"/> from the hashtable for the specified key.
314
+ /// </summary>
315
+ /// <param name="k">The key to lookup in the hashtable.</param>
316
+ /// <param name="defaultValue">The default value to return if the key does not exist or cannot be converted.</param>
317
+ /// <returns>A list of type <typeparamref name="T"/> or the default value.</returns>
178
318
  public IList<T> getList<T>(string k, IList<T> defaultValue = null)
179
319
  {
180
320
  var value0 = this.getGNArray(k);
@@ -186,16 +326,32 @@
186
326
  return defaultValue;
187
327
  }
188
328
 
329
+ /// <summary>
330
+ /// Retrieves a <see cref="GNArray"/> from the hashtable for the specified key.
331
+ /// </summary>
332
+ /// <param name="k">The key to lookup in the hashtable.</param>
333
+ /// <param name="defaultValue">The default value to return if the key does not exist or cannot be converted.</param>
334
+ /// <returns>A <see cref="GNArray"/> or the default value.</returns>
189
335
  public GNArray getGNArray(string k, GNArray defaultValue = null)
190
336
  {
191
337
  return (GNArray)this.get(k, defaultValue);
192
338
  }
193
339
 
340
+ /// <summary>
341
+ /// Retrieves a <see cref="GNHashtable"/> from the hashtable for the specified key.
342
+ /// </summary>
343
+ /// <param name="k">The key to lookup in the hashtable.</param>
344
+ /// <param name="defaultValue">The default value to return if the key does not exist or cannot be converted.</param>
345
+ /// <returns>A <see cref="GNHashtable"/> or the default value.</returns>
194
346
  public GNHashtable getGNHashtable(string k, GNHashtable defaultValue = null)
195
347
  {
196
348
  return (GNHashtable)this.get(k, defaultValue);
197
349
  }
198
350
 
351
+ /// <summary>
352
+ /// Converts the hashtable to a raw data dictionary suitable for external use.
353
+ /// </summary>
354
+ /// <returns>A dictionary containing the hashtable's key-value pairs as raw data.</returns>
199
355
  public override object toData()
200
356
  {
201
357
  var answer = new Dictionary<string, object>();
@@ -208,6 +364,10 @@
208
364
  return answer;
209
365
  }
210
366
 
367
+ /// <summary>
368
+ /// Converts the hashtable to its string representation in JSON-like format.
369
+ /// </summary>
370
+ /// <returns>A string representing the hashtable.</returns>
211
371
  public override string toString()
212
372
  {
213
373
  var stringBuilder = new StringBuilder();
@@ -220,22 +380,25 @@
220
380
 
221
381
  i++;
222
382
  var value = c.Value;
223
- if (value == null) stringBuilder.Append("\"" + c.Key.ToString() + "\"" + ":null");
224
- else if (value is GNData gnData) stringBuilder.Append("\"" + c.Key.ToString() + "\"" + ":" + gnData.ToString());
225
- else if (value is string valueStr) stringBuilder.Append("\"" + c.Key.ToString() + "\"" + ":" + "\"" + valueStr + "\"");
226
- else if (value is bool boolValue) stringBuilder.Append("\"" + c.Key.ToString() + "\"" + ":" + boolValue.ToString().ToLower());
227
- else stringBuilder.Append("\"" + c.Key.ToString() + "\"" + ":" + value);
383
+ if (value == null) stringBuilder.Append($"\"{c.Key}\":null");
384
+ else if (value is GNData gnData) stringBuilder.Append($"\"{c.Key}\":{gnData.ToString()}");
385
+ else if (value is string valueStr) stringBuilder.Append($"\"{c.Key}\":\"{valueStr}\"");
386
+ else if (value is bool boolValue) stringBuilder.Append($"\"{c.Key}\":{boolValue.ToString().ToLower()}");
387
+ else stringBuilder.Append($"\"{c.Key}\":{value}");
228
388
  }
229
389
 
230
390
  stringBuilder.Append("}");
231
391
  return stringBuilder.ToString();
232
392
  }
233
393
 
394
+ /// <summary>
395
+ /// Overrides the default <see cref="object.ToString"/> method to return the hashtable's string representation.
396
+ /// </summary>
397
+ /// <returns>A string representing the hashtable.</returns>
234
398
  public override string ToString()
235
399
  {
236
400
  return this.toString();
237
401
  }
238
-
239
402
  }
240
403
 
241
404
  }
@@ -1,11 +1,20 @@
1
1
  namespace XmobiTea.GN.Common
2
2
  {
3
+ /// <summary>
4
+ /// Interface defining the structure for GNData objects.
5
+ /// </summary>
3
6
  public interface IGNData
4
7
  {
8
+ /// <summary>
9
+ /// Converts the current GNData object into a serializable data format.
10
+ /// </summary>
11
+ /// <returns>A serializable representation of the GNData object.</returns>
5
12
  object toData();
6
13
 
14
+ /// <summary>
15
+ /// Converts the current GNData object into a string representation.
16
+ /// </summary>
17
+ /// <returns>A string representation of the GNData object.</returns>
7
18
  string toString();
8
-
9
19
  }
10
-
11
20
  }
@@ -2,25 +2,53 @@
2
2
  {
3
3
  using UnityEngine;
4
4
 
5
+ /// <summary>
6
+ /// Enum for specifying the peer socket version.
7
+ /// </summary>
5
8
  public enum PeerSocketVersion
6
9
  {
10
+ /// <summary>
11
+ /// Socket.IO version 2 with protocol v2.
12
+ /// </summary>
7
13
  V2_v2 = 0,
14
+
15
+ /// <summary>
16
+ /// Socket.IO version 2 with protocol v3.
17
+ /// </summary>
8
18
  V2_v3 = 1,
9
- V3 = 2,
10
19
 
20
+ /// <summary>
21
+ /// Socket.IO version 3.
22
+ /// </summary>
23
+ V3 = 2,
11
24
  }
12
25
 
26
+ /// <summary>
27
+ /// Enum for specifying the HTTP request type.
28
+ /// </summary>
13
29
  public enum HttpRequestType
14
30
  {
31
+ /// <summary>
32
+ /// UnityWebRequest for HTTP requests.
33
+ /// </summary>
15
34
  UnityWebRequest = 0,
16
35
 
17
36
  #if UNITY_USING_BEST_HTTP
37
+ /// <summary>
38
+ /// BestHTTP library for HTTP requests.
39
+ /// </summary>
18
40
  HTTPRequest = 1,
19
41
  #endif
20
42
 
43
+ /// <summary>
44
+ /// HttpWebRequest for HTTP requests.
45
+ /// </summary>
21
46
  HttpWebRequest = 2,
22
47
  }
23
48
 
49
+ /// <summary>
50
+ /// GN Server settings configuration.
51
+ /// </summary>
24
52
  //[CreateAssetMenu(fileName = GNServerSettings.ResourcesPath, menuName = "GN/GNServerSettings", order = 1)]
25
53
  public class GNServerSettings : ScriptableObject
26
54
  {
@@ -71,96 +99,112 @@
71
99
  [SerializeField]
72
100
  private GN.Logger.LogType logType = GN.Logger.LogType.All;
73
101
 
74
- public string getServerAddress()
75
- {
76
- return this.serverAddress;
77
- }
78
-
79
- public int getServerPort()
80
- {
81
- return this.serverPort;
82
- }
83
-
84
- public bool isUseSsl()
85
- {
86
- return this.useSsl;
87
- }
88
-
89
-
90
- public bool isUseSocket()
91
- {
92
- return this.useSocket;
93
- }
94
-
95
- public bool isUseHttp()
96
- {
97
- return this.useHttp;
98
- }
99
-
100
- public int getSendRate()
101
- {
102
- return this.sendRate;
103
- }
104
-
105
- public int getReconnectDelay()
106
- {
107
- return this.reconnectDelay;
108
- }
109
-
110
- public float getPingInterval()
111
- {
112
- return this.pingInterval;
113
- }
114
-
115
- public float getPingTimeout()
116
- {
117
- return this.pingTimeout;
118
- }
119
-
120
- public string getAdminSecretKey()
121
- {
122
- return this.adminSecretKey;
123
- }
124
-
125
- public string getServerSecretKey()
126
- {
127
- return this.serverSecretKey;
128
- }
129
-
130
- public string getClientSecretKey()
131
- {
132
- return this.clientSecretKey;
133
- }
134
-
135
- public PeerSocketVersion getPeerSocketVersion()
136
- {
137
- return this.peerSocketVersion;
138
- }
139
-
140
- public HttpRequestType getHttpRequestType()
141
- {
142
- return this.httpRequestType;
143
- }
144
-
145
- public GN.Logger.LogType getLogType()
146
- {
147
- return this.logType;
148
- }
149
-
150
-
151
- public string getSocketUrl()
152
- {
153
- if (this.serverPort < 0) return string.Format((this.useSsl ? "https" : "http") + "://{0}", this.serverAddress);
154
- else return string.Format((this.useSsl ? "https" : "http") + "://{0}:{1}", this.serverAddress, this.serverPort);
155
- }
156
-
157
- public string getHttpUrl()
158
- {
159
- if (this.serverPort < 0) return string.Format((this.useSsl ? "https" : "http") + "://{0}", this.serverAddress);
160
- else return string.Format((this.useSsl ? "https" : "http") + "://{0}:{1}", this.serverAddress, this.serverPort);
161
- }
162
-
102
+ /// <summary>
103
+ /// Gets the server address.
104
+ /// </summary>
105
+ /// <returns>The server address.</returns>
106
+ public string getServerAddress() => this.serverAddress;
107
+
108
+ /// <summary>
109
+ /// Gets the server port.
110
+ /// </summary>
111
+ /// <returns>The server port.</returns>
112
+ public int getServerPort() => this.serverPort;
113
+
114
+ /// <summary>
115
+ /// Indicates whether SSL is used.
116
+ /// </summary>
117
+ /// <returns>True if SSL is used; otherwise, false.</returns>
118
+ public bool isUseSsl() => this.useSsl;
119
+
120
+ /// <summary>
121
+ /// Indicates whether socket communication is enabled.
122
+ /// </summary>
123
+ /// <returns>True if socket is used; otherwise, false.</returns>
124
+ public bool isUseSocket() => this.useSocket;
125
+
126
+ /// <summary>
127
+ /// Indicates whether HTTP communication is enabled.
128
+ /// </summary>
129
+ /// <returns>True if HTTP is used; otherwise, false.</returns>
130
+ public bool isUseHttp() => this.useHttp;
131
+
132
+ /// <summary>
133
+ /// Gets the message send rate.
134
+ /// </summary>
135
+ /// <returns>The send rate.</returns>
136
+ public int getSendRate() => this.sendRate;
137
+
138
+ /// <summary>
139
+ /// Gets the reconnect delay in milliseconds.
140
+ /// </summary>
141
+ /// <returns>The reconnect delay.</returns>
142
+ public int getReconnectDelay() => this.reconnectDelay;
143
+
144
+ /// <summary>
145
+ /// Gets the ping interval in milliseconds.
146
+ /// </summary>
147
+ /// <returns>The ping interval.</returns>
148
+ public float getPingInterval() => this.pingInterval;
149
+
150
+ /// <summary>
151
+ /// Gets the ping timeout in milliseconds.
152
+ /// </summary>
153
+ /// <returns>The ping timeout.</returns>
154
+ public float getPingTimeout() => this.pingTimeout;
155
+
156
+ /// <summary>
157
+ /// Gets the admin secret key.
158
+ /// </summary>
159
+ /// <returns>The admin secret key.</returns>
160
+ public string getAdminSecretKey() => this.adminSecretKey;
161
+
162
+ /// <summary>
163
+ /// Gets the server secret key.
164
+ /// </summary>
165
+ /// <returns>The server secret key.</returns>
166
+ public string getServerSecretKey() => this.serverSecretKey;
167
+
168
+ /// <summary>
169
+ /// Gets the client secret key.
170
+ /// </summary>
171
+ /// <returns>The client secret key.</returns>
172
+ public string getClientSecretKey() => this.clientSecretKey;
173
+
174
+ /// <summary>
175
+ /// Gets the peer socket version.
176
+ /// </summary>
177
+ /// <returns>The peer socket version.</returns>
178
+ public PeerSocketVersion getPeerSocketVersion() => this.peerSocketVersion;
179
+
180
+ /// <summary>
181
+ /// Gets the HTTP request type.
182
+ /// </summary>
183
+ /// <returns>The HTTP request type.</returns>
184
+ public HttpRequestType getHttpRequestType() => this.httpRequestType;
185
+
186
+ /// <summary>
187
+ /// Gets the log type.
188
+ /// </summary>
189
+ /// <returns>The log type.</returns>
190
+ public GN.Logger.LogType getLogType() => this.logType;
191
+
192
+ /// <summary>
193
+ /// Constructs the socket URL.
194
+ /// </summary>
195
+ /// <returns>The socket URL.</returns>
196
+ public string getSocketUrl() =>
197
+ this.serverPort < 0
198
+ ? $"{(this.useSsl ? "https" : "http")}://{this.serverAddress}"
199
+ : $"{(this.useSsl ? "https" : "http")}://{this.serverAddress}:{this.serverPort}";
200
+
201
+ /// <summary>
202
+ /// Constructs the HTTP URL.
203
+ /// </summary>
204
+ /// <returns>The HTTP URL.</returns>
205
+ public string getHttpUrl() =>
206
+ this.serverPort < 0
207
+ ? $"{(this.useSsl ? "https" : "http")}://{this.serverAddress}"
208
+ : $"{(this.useSsl ? "https" : "http")}://{this.serverAddress}:{this.serverPort}";
163
209
  }
164
-
165
210
  }
166
-