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
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
using System.Text;
|
|
6
6
|
|
|
7
7
|
/// <summary>
|
|
8
|
-
///
|
|
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
|
|
53
|
+
var answer = new GNHashtable();
|
|
40
54
|
|
|
41
55
|
var keys = this.dict.Keys;
|
|
42
56
|
foreach (var key in keys)
|
|
43
57
|
{
|
|
44
|
-
|
|
58
|
+
answer.add(key, this.dict[key]);
|
|
45
59
|
}
|
|
46
60
|
|
|
47
|
-
return
|
|
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("\"
|
|
224
|
-
else if (value is GNData gnData) stringBuilder.Append("\"
|
|
225
|
-
else if (value is string valueStr) stringBuilder.Append("\"
|
|
226
|
-
else if (value is bool boolValue) stringBuilder.Append("\"
|
|
227
|
-
else stringBuilder.Append("\"
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
public
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
public bool
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
public
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
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
|
-
|