com.xmobitea.changx.gn-unity 2.0.3 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/GNServerSettingsEditor.cs +16 -300
- package/Runtime/Common/GNArray.cs +387 -302
- package/Runtime/Common/GNArray.cs.meta +11 -11
- package/Runtime/Common/GNData.cs +61 -48
- package/Runtime/Common/GNData.cs.meta +11 -11
- package/Runtime/Common/GNHashtable.cs +404 -241
- package/Runtime/Common/GNHashtable.cs.meta +11 -11
- package/Runtime/Common/IGNData.cs +20 -11
- package/Runtime/Common/IGNData.cs.meta +11 -11
- package/Runtime/Common.meta +8 -8
- package/Runtime/Config/GNServerSettings.cs +136 -92
- package/Runtime/Config/GNServerSettings.cs.meta +11 -11
- package/Runtime/Config.meta +8 -8
- package/Runtime/Constant/Commands.cs +82 -19
- package/Runtime/Constant/Commands.cs.meta +11 -11
- package/Runtime/Constant/EnumType/FriendStatus.cs +12 -12
- package/Runtime/Constant/EnumType/FriendStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/GoogleLoginType.cs +5 -5
- package/Runtime/Constant/EnumType/GoogleLoginType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/GroupStatus.cs +7 -7
- package/Runtime/Constant/EnumType/GroupStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/InvalidMemberType.cs +23 -23
- package/Runtime/Constant/EnumType/InvalidMemberType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/ItemType.cs +5 -5
- package/Runtime/Constant/EnumType/ItemType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/MatchmakingMemberStatus.cs +6 -6
- package/Runtime/Constant/EnumType/MatchmakingMemberStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/MatchmakingTicketStatus.cs +2 -2
- package/Runtime/Constant/EnumType/MatchmakingTicketStatus.cs.meta +11 -11
- package/Runtime/Constant/EnumType/OwnerType.cs +3 -2
- package/Runtime/Constant/EnumType/OwnerType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/PermissionDataItem.cs +10 -10
- package/Runtime/Constant/EnumType/PermissionDataItem.cs.meta +11 -11
- package/Runtime/Constant/EnumType/PushPlatformType.cs +10 -0
- package/Runtime/Constant/EnumType/PushPlatformType.cs.meta +11 -0
- package/Runtime/Constant/EnumType/RequestRole.cs +11 -11
- package/Runtime/Constant/EnumType/RequestRole.cs.meta +7 -7
- package/Runtime/Constant/EnumType/RequestType.cs +20 -19
- package/Runtime/Constant/EnumType/RequestType.cs.meta +11 -11
- package/Runtime/Constant/EnumType/StoreReceiveType.cs +13 -0
- package/Runtime/Constant/EnumType/StoreReceiveType.cs.meta +11 -0
- package/Runtime/Constant/EnumType.meta +8 -8
- package/Runtime/Constant/ErrorCode/GNErrorCode.cs +53 -48
- package/Runtime/Constant/ErrorCode/GNErrorCode.cs.meta +7 -7
- package/Runtime/Constant/ErrorCode.meta +8 -8
- package/Runtime/Constant/EventCode.cs +43 -16
- package/Runtime/Constant/EventCode.cs.meta +11 -11
- package/Runtime/Constant/OperationCode.cs +249 -211
- package/Runtime/Constant/OperationCode.cs.meta +11 -11
- package/Runtime/Constant/ParameterCode/GNParameterCode.cs +614 -466
- package/Runtime/Constant/ParameterCode/GNParameterCode.cs.meta +11 -11
- package/Runtime/Constant/ParameterCode/ParameterCode.cs +12 -12
- package/Runtime/Constant/ParameterCode/ParameterCode.cs.meta +11 -11
- package/Runtime/Constant/ParameterCode.meta +8 -8
- package/Runtime/Constant/ReturnCode.cs +73 -25
- package/Runtime/Constant/ReturnCode.cs.meta +11 -11
- package/Runtime/Constant.meta +8 -8
- package/Runtime/Entity/DataMember.cs +342 -124
- package/Runtime/Entity/DataMember.cs.meta +11 -11
- package/Runtime/Entity/GNMetadata.cs +72 -27
- package/Runtime/Entity/GNMetadata.cs.meta +11 -11
- package/Runtime/Entity/InvalidMember.cs +52 -33
- package/Runtime/Entity/InvalidMember.cs.meta +11 -11
- package/Runtime/Entity/Models/AuthenticateModels.cs +251 -207
- package/Runtime/Entity/Models/AuthenticateModels.cs.meta +11 -11
- package/Runtime/Entity/Models/AuthenticateRequestModels.cs +153 -131
- package/Runtime/Entity/Models/AuthenticateRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/AuthenticateResponseModels.cs +61 -51
- package/Runtime/Entity/Models/AuthenticateResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CharacterPlayerModels.cs +985 -849
- package/Runtime/Entity/Models/CharacterPlayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CharacterPlayerRequestModels.cs +957 -885
- package/Runtime/Entity/Models/CharacterPlayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CharacterPlayerResponseModels.cs +165 -150
- package/Runtime/Entity/Models/CharacterPlayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/CloudScriptModels.cs +185 -0
- package/Runtime/Entity/Models/CloudScriptModels.cs.meta +11 -0
- package/Runtime/Entity/Models/CloudScriptRequestModels.cs +134 -0
- package/Runtime/Entity/Models/CloudScriptRequestModels.cs.meta +11 -0
- package/Runtime/Entity/Models/CloudScriptResponseModels.cs +34 -0
- package/Runtime/Entity/Models/CloudScriptResponseModels.cs.meta +11 -0
- package/Runtime/Entity/Models/ContentModels.cs +150 -153
- package/Runtime/Entity/Models/ContentModels.cs.meta +11 -11
- package/Runtime/Entity/Models/ContentRequestModels.cs +129 -129
- package/Runtime/Entity/Models/ContentRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/ContentResponseModels.cs +24 -24
- package/Runtime/Entity/Models/ContentResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/DashboardModels.cs +1684 -1156
- package/Runtime/Entity/Models/DashboardModels.cs.meta +11 -11
- package/Runtime/Entity/Models/DashboardRequestModels.cs +220 -147
- package/Runtime/Entity/Models/DashboardRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/DashboardResponseModels.cs +92 -57
- package/Runtime/Entity/Models/DashboardResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GamePlayerModels.cs +1073 -933
- package/Runtime/Entity/Models/GamePlayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GamePlayerRequestModels.cs +939 -867
- package/Runtime/Entity/Models/GamePlayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GamePlayerResponseModels.cs +162 -147
- package/Runtime/Entity/Models/GamePlayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GenericModels.cs +102 -102
- package/Runtime/Entity/Models/GenericModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GroupModels.cs +812 -676
- package/Runtime/Entity/Models/GroupModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GroupRequestModels.cs +741 -669
- package/Runtime/Entity/Models/GroupRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/GroupResponseModels.cs +129 -114
- package/Runtime/Entity/Models/GroupResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/InventoryModels.cs +667 -558
- package/Runtime/Entity/Models/InventoryModels.cs.meta +11 -11
- package/Runtime/Entity/Models/InventoryRequestModels.cs +626 -579
- package/Runtime/Entity/Models/InventoryRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/InventoryResponseModels.cs +109 -99
- package/Runtime/Entity/Models/InventoryResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MasterPlayerModels.cs +1882 -1340
- package/Runtime/Entity/Models/MasterPlayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MasterPlayerRequestModels.cs +1643 -1253
- package/Runtime/Entity/Models/MasterPlayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MasterPlayerResponseModels.cs +293 -213
- package/Runtime/Entity/Models/MasterPlayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MultiplayerModels.cs +293 -223
- package/Runtime/Entity/Models/MultiplayerModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MultiplayerRequestModels.cs +199 -149
- package/Runtime/Entity/Models/MultiplayerRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/MultiplayerResponseModels.cs +59 -49
- package/Runtime/Entity/Models/MultiplayerResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models/StoreInventoryModels.cs +514 -323
- package/Runtime/Entity/Models/StoreInventoryModels.cs.meta +11 -11
- package/Runtime/Entity/Models/StoreInventoryRequestModels.cs +236 -165
- package/Runtime/Entity/Models/StoreInventoryRequestModels.cs.meta +11 -11
- package/Runtime/Entity/Models/StoreInventoryResponseModels.cs +45 -30
- package/Runtime/Entity/Models/StoreInventoryResponseModels.cs.meta +11 -11
- package/Runtime/Entity/Models.meta +8 -8
- package/Runtime/Entity/OperationEvent.cs +111 -75
- package/Runtime/Entity/OperationEvent.cs.meta +11 -11
- package/Runtime/Entity/OperationHelper.cs +51 -35
- package/Runtime/Entity/OperationHelper.cs.meta +11 -11
- package/Runtime/Entity/OperationRequest.cs +142 -99
- package/Runtime/Entity/OperationRequest.cs.meta +11 -11
- package/Runtime/Entity/OperationResponse.cs +111 -63
- package/Runtime/Entity/OperationResponse.cs.meta +11 -11
- package/Runtime/Entity/Request/CustomOperationRequest.cs +112 -61
- package/Runtime/Entity/Request/CustomOperationRequest.cs.meta +11 -11
- package/Runtime/Entity/Request.meta +8 -8
- package/Runtime/Entity/Response/CustomOperationResponse.cs +84 -63
- package/Runtime/Entity/Response/CustomOperationResponse.cs.meta +11 -11
- package/Runtime/Entity/Response.meta +8 -8
- package/Runtime/Entity.meta +8 -8
- package/Runtime/GNNetwork.cs +501 -182
- package/Runtime/GNNetwork.cs.meta +11 -11
- package/Runtime/GNNetworkApi.cs +38 -19
- package/Runtime/GNNetworkApi.cs.meta +11 -11
- package/Runtime/GNNetworkAuthenticateApi.cs +531 -98
- package/Runtime/GNNetworkAuthenticateApi.cs.meta +11 -11
- package/Runtime/GNNetworkCharacterPlayerApi.cs +1587 -762
- package/Runtime/GNNetworkCharacterPlayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkCloudScriptApi.cs +181 -0
- package/Runtime/GNNetworkCloudScriptApi.cs.meta +11 -0
- package/Runtime/GNNetworkContentApi.cs +238 -132
- package/Runtime/GNNetworkContentApi.cs.meta +11 -11
- package/Runtime/GNNetworkDashboardApi.cs +278 -117
- package/Runtime/GNNetworkDashboardApi.cs.meta +11 -11
- package/Runtime/GNNetworkGamePlayerApi.cs +1558 -747
- package/Runtime/GNNetworkGamePlayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkGroupApi.cs +1228 -582
- package/Runtime/GNNetworkGroupApi.cs.meta +11 -11
- package/Runtime/GNNetworkInventoryApi.cs +1048 -507
- package/Runtime/GNNetworkInventoryApi.cs.meta +11 -11
- package/Runtime/GNNetworkMasterPlayerApi.cs +2586 -1067
- package/Runtime/GNNetworkMasterPlayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkMultiplayerApi.cs +328 -147
- package/Runtime/GNNetworkMultiplayerApi.cs.meta +11 -11
- package/Runtime/GNNetworkStoreInventoryApi.cs +388 -162
- package/Runtime/GNNetworkStoreInventoryApi.cs.meta +11 -11
- package/Runtime/Helper/CodeHelper.cs +140 -98
- package/Runtime/Helper/CodeHelper.cs.meta +11 -11
- package/Runtime/Helper/ConverterService.cs +236 -52
- package/Runtime/Helper/ConverterService.cs.meta +11 -11
- package/Runtime/Helper/ParseGNHelper.cs +451 -451
- package/Runtime/Helper/ParseGNHelper.cs.meta +11 -11
- package/Runtime/Helper.meta +8 -8
- package/Runtime/Logger/GNDebug.cs +92 -49
- package/Runtime/Logger/GNDebug.cs.meta +11 -11
- package/Runtime/Logger.meta +8 -8
- package/Runtime/Networking/AuthenticateStatus.cs +57 -35
- package/Runtime/Networking/AuthenticateStatus.cs.meta +11 -11
- package/Runtime/Networking/Handler/IServerEventHandler.cs +25 -25
- package/Runtime/Networking/Handler/IServerEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnCharacterPlayerFriendUpdateEventHandler.cs +61 -32
- package/Runtime/Networking/Handler/OnCharacterPlayerFriendUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnCharacterPlayerGroupUpdateEventHandler.cs +54 -33
- package/Runtime/Networking/Handler/OnCharacterPlayerGroupUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGamePlayerFriendUpdateEventHandler.cs +54 -32
- package/Runtime/Networking/Handler/OnGamePlayerFriendUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGamePlayerGroupUpdateEventHandler.cs +54 -32
- package/Runtime/Networking/Handler/OnGamePlayerGroupUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGroupMemberUpdateEventHandler.cs +48 -29
- package/Runtime/Networking/Handler/OnGroupMemberUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler/OnGroupMessageUpdateEventHandler.cs +47 -29
- package/Runtime/Networking/Handler/OnGroupMessageUpdateEventHandler.cs.meta +11 -11
- package/Runtime/Networking/Handler.meta +8 -8
- package/Runtime/Networking/Http/HttpPeer.cs +68 -25
- package/Runtime/Networking/Http/HttpPeer.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingHttpPeerBase.cs +65 -25
- package/Runtime/Networking/Http/NetworkingHttpPeerBase.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingPeerHttpClientRequest.cs +513 -486
- package/Runtime/Networking/Http/NetworkingPeerHttpClientRequest.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingPeerHttpRequest.cs +172 -142
- package/Runtime/Networking/Http/NetworkingPeerHttpRequest.cs.meta +11 -11
- package/Runtime/Networking/Http/NetworkingPeerUnityWebRequest.cs +225 -188
- package/Runtime/Networking/Http/NetworkingPeerUnityWebRequest.cs.meta +11 -11
- package/Runtime/Networking/Http.meta +8 -8
- package/Runtime/Networking/IPeer.cs +41 -19
- package/Runtime/Networking/IPeer.cs.meta +11 -11
- package/Runtime/Networking/NetworkingPeer.cs +198 -144
- package/Runtime/Networking/NetworkingPeer.cs.meta +11 -11
- package/Runtime/Networking/NetworkingPeerAPI.cs +20 -21
- package/Runtime/Networking/NetworkingPeerAPI.cs.meta +11 -11
- package/Runtime/Networking/OperationPending.cs +159 -95
- package/Runtime/Networking/OperationPending.cs.meta +11 -11
- package/Runtime/Networking/PeerBase.cs +305 -242
- package/Runtime/Networking/PeerBase.cs.meta +11 -11
- package/Runtime/Networking/Socket/NetworkingPeerSocketV2.cs +222 -185
- package/Runtime/Networking/Socket/NetworkingPeerSocketV2.cs.meta +11 -11
- package/Runtime/Networking/Socket/NetworkingPeerSocketV3.cs +235 -177
- package/Runtime/Networking/Socket/NetworkingPeerSocketV3.cs.meta +11 -11
- package/Runtime/Networking/Socket/NetworkingSocketPeerBase.cs +165 -23
- package/Runtime/Networking/Socket/NetworkingSocketPeerBase.cs.meta +11 -11
- package/Runtime/Networking/Socket/SocketPeer.cs +242 -197
- package/Runtime/Networking/Socket/SocketPeer.cs.meta +11 -11
- package/Runtime/Networking/Socket.meta +8 -8
- package/Runtime/Networking.meta +8 -8
- package/Runtime/Unity/ServiceCoroutine.cs +10 -0
- package/Runtime/Unity/ServiceCoroutine.cs.meta +11 -0
- package/Runtime/Unity/ServiceUpdate.cs +33 -20
- package/Runtime/Unity/ServiceUpdate.cs.meta +11 -11
- package/Runtime/Unity.meta +8 -8
- package/Runtime/XmobiTea.GN.runtime.asmdef +16 -16
- package/Runtime/XmobiTea.GN.runtime.asmdef.meta +7 -7
- package/package.json +1 -1
|
@@ -1,144 +1,198 @@
|
|
|
1
|
-
namespace XmobiTea.GN.Networking
|
|
2
|
-
{
|
|
3
|
-
using System;
|
|
4
|
-
using XmobiTea.GN.Common;
|
|
5
|
-
using XmobiTea.GN.Constant;
|
|
6
|
-
using XmobiTea.GN.Entity;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
this.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
this.
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
this.
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
(
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
internal void
|
|
138
|
-
{
|
|
139
|
-
(this.socketPeer as Socket.SocketPeer).
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
1
|
+
namespace XmobiTea.GN.Networking
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using XmobiTea.GN.Common;
|
|
5
|
+
using XmobiTea.GN.Constant;
|
|
6
|
+
using XmobiTea.GN.Entity;
|
|
7
|
+
|
|
8
|
+
/// <summary>
|
|
9
|
+
/// Manages networking peers for HTTP and socket communication.
|
|
10
|
+
/// </summary>
|
|
11
|
+
public partial class NetworkingPeer
|
|
12
|
+
{
|
|
13
|
+
private IPeer socketPeer; // Socket peer instance.
|
|
14
|
+
private IPeer httpPeer; // HTTP peer instance.
|
|
15
|
+
|
|
16
|
+
internal AuthenticateStatus authenticateStatus; // Stores authentication status.
|
|
17
|
+
internal string gameId;
|
|
18
|
+
|
|
19
|
+
/// <summary>
|
|
20
|
+
/// Calculates and returns the average ping between HTTP and socket peers.
|
|
21
|
+
/// </summary>
|
|
22
|
+
/// <returns>The average ping in milliseconds.</returns>
|
|
23
|
+
internal int getPing()
|
|
24
|
+
{
|
|
25
|
+
var count = 0;
|
|
26
|
+
var totalPing = 0;
|
|
27
|
+
|
|
28
|
+
if (this.httpPeer.isUsing())
|
|
29
|
+
{
|
|
30
|
+
count++;
|
|
31
|
+
totalPing += ((PeerBase)this.httpPeer).ping;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
if (this.socketPeer.isUsing())
|
|
35
|
+
{
|
|
36
|
+
count++;
|
|
37
|
+
totalPing += ((PeerBase)this.socketPeer).ping;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return count > 0 ? totalPing / count : -1;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/// <summary>
|
|
44
|
+
/// Gets the client ID of the socket connection.
|
|
45
|
+
/// </summary>
|
|
46
|
+
/// <returns>The client ID as a string.</returns>
|
|
47
|
+
internal string getClientId()
|
|
48
|
+
{
|
|
49
|
+
return (this.socketPeer as Socket.SocketPeer).getClientId();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
private long lastCurrentServerMilliseconds; // The last known server time in milliseconds.
|
|
53
|
+
private float lastGetCurrentMilliseconds; // The local time in seconds when the server time was last updated.
|
|
54
|
+
|
|
55
|
+
/// <summary>
|
|
56
|
+
/// Sets the current server time in milliseconds.
|
|
57
|
+
/// </summary>
|
|
58
|
+
/// <param name="currentServerMilliseconds">The server time in milliseconds.</param>
|
|
59
|
+
internal void setServerTimeMilliseconds(long currentServerMilliseconds)
|
|
60
|
+
{
|
|
61
|
+
this.lastCurrentServerMilliseconds = currentServerMilliseconds;
|
|
62
|
+
this.lastGetCurrentMilliseconds = UnityEngine.Time.realtimeSinceStartup;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/// <summary>
|
|
66
|
+
/// Gets the current server timestamp in milliseconds.
|
|
67
|
+
/// </summary>
|
|
68
|
+
/// <returns>The current server timestamp.</returns>
|
|
69
|
+
internal long getServerTimestamp()
|
|
70
|
+
{
|
|
71
|
+
return this.lastCurrentServerMilliseconds + (int)((UnityEngine.Time.realtimeSinceStartup - this.lastGetCurrentMilliseconds) * 1000);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/// <summary>
|
|
75
|
+
/// Initializes the HTTP and socket peers.
|
|
76
|
+
/// </summary>
|
|
77
|
+
internal void initPeer()
|
|
78
|
+
{
|
|
79
|
+
this.setServerTimeMilliseconds(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
|
|
80
|
+
|
|
81
|
+
var gnServerSettings = GNNetwork.gnServerSettings;
|
|
82
|
+
if (gnServerSettings == null) throw new NullReferenceException("Null GN Server Settings, please find it now");
|
|
83
|
+
|
|
84
|
+
this.authenticateStatus = new AuthenticateStatus();
|
|
85
|
+
|
|
86
|
+
this.httpPeer = new Http.HttpPeer();
|
|
87
|
+
this.httpPeer.initPeer();
|
|
88
|
+
|
|
89
|
+
this.socketPeer = new Socket.SocketPeer();
|
|
90
|
+
this.socketPeer.initPeer();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/// <summary>
|
|
94
|
+
/// Processes pending operations for both HTTP and socket peers.
|
|
95
|
+
/// </summary>
|
|
96
|
+
internal void service()
|
|
97
|
+
{
|
|
98
|
+
this.httpPeer?.service();
|
|
99
|
+
this.socketPeer?.service();
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/// <summary>
|
|
103
|
+
/// Sends a request via socket peer.
|
|
104
|
+
/// </summary>
|
|
105
|
+
internal void sendViaSocket(RequestType requestType, RequestRole requestRole, OperationRequest request, Action<OperationResponse> onResponse = null, string authToken = null, string secretKey = null, GNHashtable customTags = null)
|
|
106
|
+
{
|
|
107
|
+
if (authToken == null) authToken = GNNetwork.getAuthenticateStatus().getAuthToken();
|
|
108
|
+
if (secretKey == null)
|
|
109
|
+
{
|
|
110
|
+
if (requestRole == RequestRole.Admin) secretKey = GNNetwork.gnServerSettings.getAdminSecretKey();
|
|
111
|
+
else if (requestRole == RequestRole.Server) secretKey = GNNetwork.gnServerSettings.getServerSecretKey();
|
|
112
|
+
else if (requestRole == RequestRole.Client) secretKey = GNNetwork.gnServerSettings.getClientSecretKey();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
this.socketPeer.enqueue(requestType, requestRole, request, onResponse, authToken, secretKey, customTags, this.gameId);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/// <summary>
|
|
119
|
+
/// Sends a request via HTTP peer.
|
|
120
|
+
/// </summary>
|
|
121
|
+
internal void sendViaHttp(RequestType requestType, RequestRole requestRole, OperationRequest request, Action<OperationResponse> onResponse = null, string authToken = null, string secretKey = null, GNHashtable customTags = null)
|
|
122
|
+
{
|
|
123
|
+
if (authToken == null) authToken = this.authenticateStatus.getAuthToken();
|
|
124
|
+
if (secretKey == null)
|
|
125
|
+
{
|
|
126
|
+
if (requestRole == RequestRole.Admin) secretKey = GNNetwork.gnServerSettings.getAdminSecretKey();
|
|
127
|
+
else if (requestRole == RequestRole.Server) secretKey = GNNetwork.gnServerSettings.getServerSecretKey();
|
|
128
|
+
else if (requestRole == RequestRole.Client) secretKey = GNNetwork.gnServerSettings.getClientSecretKey();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
this.httpPeer.enqueue(requestType, requestRole, request, onResponse, authToken, secretKey, customTags, this.gameId);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/// <summary>
|
|
135
|
+
/// Sends an authentication request via socket.
|
|
136
|
+
/// </summary>
|
|
137
|
+
internal void sendRequestAuthSocket()
|
|
138
|
+
{
|
|
139
|
+
(this.socketPeer as Socket.SocketPeer).sendRequestAuthSocket();
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/// <summary>
|
|
143
|
+
/// Connects to the socket with a specified callback.
|
|
144
|
+
/// </summary>
|
|
145
|
+
internal void connectSocket(Action _onSocketConnect)
|
|
146
|
+
{
|
|
147
|
+
(this.socketPeer as Socket.SocketPeer).connect(_onSocketConnect);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/// <summary>
|
|
151
|
+
/// Disconnects the socket with a specified callback.
|
|
152
|
+
/// </summary>
|
|
153
|
+
internal void disconnectSocket(Action _onSocketDisconnect)
|
|
154
|
+
{
|
|
155
|
+
(this.socketPeer as Socket.SocketPeer).disconnect(_onSocketDisconnect);
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/// <summary>
|
|
159
|
+
/// Sets the handler for processing socket events.
|
|
160
|
+
/// </summary>
|
|
161
|
+
internal void setOnEventHandler(Action<OperationEvent> _onEventHandler)
|
|
162
|
+
{
|
|
163
|
+
(this.socketPeer as Socket.SocketPeer).setOnEventHandler(_onEventHandler);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/// <summary>
|
|
167
|
+
/// Sets a handler for socket connection events.
|
|
168
|
+
/// </summary>
|
|
169
|
+
internal void setOnConnectHandler(Action _onConnectHandler)
|
|
170
|
+
{
|
|
171
|
+
(this.socketPeer as Socket.SocketPeer).setOnConnectHandler(_onConnectHandler);
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/// <summary>
|
|
175
|
+
/// Sets a handler for socket disconnection events.
|
|
176
|
+
/// </summary>
|
|
177
|
+
internal void setOnDisconnectHandler(Action _onDisconnectHandler)
|
|
178
|
+
{
|
|
179
|
+
(this.socketPeer as Socket.SocketPeer).setOnDisconnectHandler(_onDisconnectHandler);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/// <summary>
|
|
183
|
+
/// Removes the handler for socket connection events.
|
|
184
|
+
/// </summary>
|
|
185
|
+
internal void removeOnConnectHandler(Action _onConnectHandler)
|
|
186
|
+
{
|
|
187
|
+
(this.socketPeer as Socket.SocketPeer).removeOnConnectHandler(_onConnectHandler);
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/// <summary>
|
|
191
|
+
/// Removes the handler for socket disconnection events.
|
|
192
|
+
/// </summary>
|
|
193
|
+
internal void removeOnDisconnectHandler(Action _onDisconnectHandler)
|
|
194
|
+
{
|
|
195
|
+
(this.socketPeer as Socket.SocketPeer).removeOnDisconnectHandler(_onDisconnectHandler);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 69c4e5d71765aaa45a73e7dddac28586
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 69c4e5d71765aaa45a73e7dddac28586
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -4,33 +4,44 @@
|
|
|
4
4
|
using System.Collections;
|
|
5
5
|
using XmobiTea.GN.Common;
|
|
6
6
|
using XmobiTea.GN.Constant;
|
|
7
|
-
using XmobiTea.GN.Entity.Response;
|
|
8
7
|
using XmobiTea.GN.Helper;
|
|
9
8
|
|
|
9
|
+
/// <summary>
|
|
10
|
+
/// Provides additional functionality for managing network peers.
|
|
11
|
+
/// </summary>
|
|
10
12
|
public partial class NetworkingPeer
|
|
11
13
|
{
|
|
12
|
-
internal const string SYNC_TS = "ts";
|
|
13
|
-
internal const string UPLOAD_FILE = "upload";
|
|
14
|
-
internal const string DOWNLOAD_FILE = "download";
|
|
15
|
-
internal const string API_JSON = "api/" + Commands.RequestCmd_Json;
|
|
16
|
-
internal const string API_MSG_PACK = "api/" + Commands.RequestCmd_MsgPack;
|
|
17
|
-
|
|
14
|
+
internal const string SYNC_TS = "ts"; // API endpoint for synchronizing timestamps.
|
|
15
|
+
internal const string UPLOAD_FILE = "upload"; // API endpoint for file uploads.
|
|
16
|
+
internal const string DOWNLOAD_FILE = "download"; // API endpoint for file downloads.
|
|
17
|
+
internal const string API_JSON = "api/" + Commands.RequestCmd_Json; // Base path for JSON API requests.
|
|
18
|
+
internal const string API_MSG_PACK = "api/" + Commands.RequestCmd_MsgPack; // Base path for MsgPack API requests.
|
|
19
|
+
|
|
20
|
+
/// <summary>
|
|
21
|
+
/// Synchronizes the local time with the server time by retrieving the latest server timestamp.
|
|
22
|
+
/// </summary>
|
|
23
|
+
/// <param name="onResponse">An optional callback to handle the synchronized server timestamp.</param>
|
|
18
24
|
internal void syncTs(Action<long> onResponse = null)
|
|
19
25
|
{
|
|
26
|
+
// Sends a request to the SYNC_TS endpoint using the HTTP peer.
|
|
20
27
|
(this.httpPeer as Http.HttpPeer).getRequest(NetworkingPeer.SYNC_TS, httpAppResponse =>
|
|
21
28
|
{
|
|
29
|
+
// Processes the response if there is no error.
|
|
22
30
|
if (!httpAppResponse.hasError())
|
|
23
31
|
{
|
|
24
|
-
if (httpAppResponse.statusCode == 200)
|
|
32
|
+
if (httpAppResponse.statusCode == 200) // HTTP success status.
|
|
25
33
|
{
|
|
34
|
+
// Parses the response text into a list and converts it to a GNArray.
|
|
26
35
|
var returnDatas = (IList)Parser.Parse(httpAppResponse.text);
|
|
27
36
|
var gnArray = new GNArray.Builder()
|
|
28
37
|
.addAll(returnDatas)
|
|
29
38
|
.build();
|
|
30
39
|
|
|
40
|
+
// Extracts the return code and checks if the operation was successful.
|
|
31
41
|
var returnCode = gnArray.getInt(0);
|
|
32
42
|
if (returnCode == ReturnCode.Ok)
|
|
33
43
|
{
|
|
44
|
+
// Retrieves the server timestamp from the response and updates the local timestamp.
|
|
34
45
|
var gnHashtable = gnArray.getGNHashtable(1);
|
|
35
46
|
var newServerTimestamp = gnHashtable.getLong("1", DateTimeOffset.UtcNow.ToUnixTimeMilliseconds());
|
|
36
47
|
|
|
@@ -39,21 +50,9 @@
|
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
52
|
|
|
53
|
+
// Invokes the callback with the current server timestamp.
|
|
42
54
|
onResponse?.Invoke(this.getServerTimestamp());
|
|
43
55
|
});
|
|
44
56
|
}
|
|
45
|
-
|
|
46
|
-
//internal void accountLogin(string username, string password, Action<LoginOperationResponse> onResponse = null)
|
|
47
|
-
//{
|
|
48
|
-
// //var request = new AccountLoginOperationRequest(username, password).Build();
|
|
49
|
-
|
|
50
|
-
// //SendViaHttp(request, response =>
|
|
51
|
-
// //{
|
|
52
|
-
// // var loginOperationResponse = new LoginOperationResponse();
|
|
53
|
-
// // loginOperationResponse.SetupOperationResponse(response);
|
|
54
|
-
|
|
55
|
-
// // onResponse?.Invoke(loginOperationResponse);
|
|
56
|
-
// //});
|
|
57
|
-
//}
|
|
58
57
|
}
|
|
59
58
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: b52091d6ac295314a875773e185b6d76
|
|
3
|
-
MonoImporter:
|
|
4
|
-
externalObjects: {}
|
|
5
|
-
serializedVersion: 2
|
|
6
|
-
defaultReferences: []
|
|
7
|
-
executionOrder: 0
|
|
8
|
-
icon: {instanceID: 0}
|
|
9
|
-
userData:
|
|
10
|
-
assetBundleName:
|
|
11
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: b52091d6ac295314a875773e185b6d76
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|