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,199 +1,244 @@
|
|
|
1
|
-
namespace XmobiTea.GN.Networking.Socket
|
|
2
|
-
{
|
|
3
|
-
using System;
|
|
4
|
-
using System.Collections.Generic;
|
|
5
|
-
using System.Linq;
|
|
6
|
-
using XmobiTea.GN.Common;
|
|
7
|
-
using XmobiTea.GN.Config;
|
|
8
|
-
using XmobiTea.GN.Entity;
|
|
9
|
-
using XmobiTea.GN.Logger;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
private
|
|
17
|
-
|
|
18
|
-
private Action<OperationEvent> _onEventHandler;
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
serverEventHandlers.Add(srvMsg);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
internal override void initGNSocketObject()
|
|
69
|
-
{
|
|
70
|
-
var gnServerSettings = GNNetwork.gnServerSettings;
|
|
71
|
-
if (gnServerSettings == null) throw new NullReferenceException("Where is GN Server Settings");
|
|
72
|
-
|
|
73
|
-
this.isUse = gnServerSettings.isUseSocket();
|
|
74
|
-
|
|
75
|
-
var peerSocketVersion = gnServerSettings.getPeerSocketVersion();
|
|
76
|
-
|
|
77
|
-
if (peerSocketVersion == PeerSocketVersion.V3)
|
|
1
|
+
namespace XmobiTea.GN.Networking.Socket
|
|
2
|
+
{
|
|
3
|
+
using System;
|
|
4
|
+
using System.Collections.Generic;
|
|
5
|
+
using System.Linq;
|
|
6
|
+
using XmobiTea.GN.Common;
|
|
7
|
+
using XmobiTea.GN.Config;
|
|
8
|
+
using XmobiTea.GN.Entity;
|
|
9
|
+
using XmobiTea.GN.Logger;
|
|
10
|
+
|
|
11
|
+
/// <summary>
|
|
12
|
+
/// Manages socket communication for the application.
|
|
13
|
+
/// </summary>
|
|
14
|
+
internal class SocketPeer : PeerBase
|
|
15
|
+
{
|
|
16
|
+
private NetworkingSocketPeerBase networkingSocketPeerBase;
|
|
17
|
+
private Dictionary<int, List<IServerEventHandler>> serverEventHandlersDict;
|
|
18
|
+
private Action<OperationEvent> _onEventHandler;
|
|
19
|
+
|
|
20
|
+
/// <summary>
|
|
21
|
+
/// Gets the client ID of the socket connection.
|
|
22
|
+
/// </summary>
|
|
23
|
+
/// <returns>The client ID as a string.</returns>
|
|
24
|
+
internal string getClientId()
|
|
25
|
+
{
|
|
26
|
+
return this.networkingSocketPeerBase?.clientId;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/// <summary>
|
|
30
|
+
/// Checks if the socket connection is established.
|
|
31
|
+
/// </summary>
|
|
32
|
+
/// <returns>True if connected, otherwise false.</returns>
|
|
33
|
+
internal bool isConnected()
|
|
34
|
+
{
|
|
35
|
+
return this.networkingSocketPeerBase.isWsConnected;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/// <summary>
|
|
39
|
+
/// Sends an authentication request via the socket.
|
|
40
|
+
/// </summary>
|
|
41
|
+
internal void sendRequestAuthSocket()
|
|
42
|
+
{
|
|
43
|
+
this.networkingSocketPeerBase.sendRequestAuthSocket();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/// <summary>
|
|
47
|
+
/// Subscribes server event handlers by scanning the current assembly.
|
|
48
|
+
/// </summary>
|
|
49
|
+
void subscriberServerEventHandler()
|
|
50
|
+
{
|
|
51
|
+
if (this.serverEventHandlersDict == null)
|
|
52
|
+
this.serverEventHandlersDict = new Dictionary<int, List<IServerEventHandler>>();
|
|
53
|
+
else
|
|
54
|
+
this.serverEventHandlersDict.Clear();
|
|
55
|
+
|
|
56
|
+
var type = typeof(IServerEventHandler);
|
|
57
|
+
var types = AppDomain.CurrentDomain.GetAssemblies()
|
|
58
|
+
.SelectMany(s => s.GetTypes())
|
|
59
|
+
.Where(p => type.IsAssignableFrom(p) && p != type).ToList();
|
|
60
|
+
|
|
61
|
+
foreach (var t in types)
|
|
78
62
|
{
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
63
|
+
var srvMsg = Activator.CreateInstance(t) as IServerEventHandler;
|
|
64
|
+
if (srvMsg != null)
|
|
65
|
+
{
|
|
66
|
+
List<IServerEventHandler> serverEventHandlers;
|
|
67
|
+
|
|
68
|
+
if (!this.serverEventHandlersDict.ContainsKey(srvMsg.getEventCode()))
|
|
69
|
+
{
|
|
70
|
+
serverEventHandlers = new List<IServerEventHandler>();
|
|
71
|
+
|
|
72
|
+
this.serverEventHandlersDict[srvMsg.getEventCode()] = serverEventHandlers;
|
|
73
|
+
}
|
|
74
|
+
else
|
|
75
|
+
{
|
|
76
|
+
serverEventHandlers = this.serverEventHandlersDict[srvMsg.getEventCode()];
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
serverEventHandlers.Add(srvMsg);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/// <summary>
|
|
85
|
+
/// Initializes the socket object with server settings.
|
|
86
|
+
/// </summary>
|
|
87
|
+
internal override void initGNSocketObject()
|
|
88
|
+
{
|
|
89
|
+
var gnServerSettings = GNNetwork.gnServerSettings;
|
|
90
|
+
if (gnServerSettings == null) throw new NullReferenceException("Where is GN Server Settings");
|
|
91
|
+
|
|
92
|
+
this.isUse = gnServerSettings.isUseSocket();
|
|
93
|
+
|
|
94
|
+
var peerSocketVersion = gnServerSettings.getPeerSocketVersion();
|
|
95
|
+
|
|
96
|
+
if (peerSocketVersion == PeerSocketVersion.V3)
|
|
84
97
|
{
|
|
85
|
-
#if UNITY_USING_BEST_HTTP
|
|
86
|
-
this.networkingSocketPeerBase = new
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
this.networkingSocketPeerBase
|
|
106
|
-
|
|
107
|
-
this.
|
|
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
|
-
internal void
|
|
136
|
-
{
|
|
137
|
-
this.networkingSocketPeerBase.
|
|
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
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
98
|
+
#if UNITY_USING_BEST_HTTP
|
|
99
|
+
this.networkingSocketPeerBase = new NetworkingPeerSocketV3();
|
|
100
|
+
#endif
|
|
101
|
+
}
|
|
102
|
+
else
|
|
103
|
+
{
|
|
104
|
+
#if UNITY_USING_BEST_HTTP
|
|
105
|
+
this.networkingSocketPeerBase = new NetworkingPeerSocketV2();
|
|
106
|
+
|
|
107
|
+
if (peerSocketVersion == PeerSocketVersion.V2_v2)
|
|
108
|
+
{
|
|
109
|
+
((NetworkingPeerSocketV2)this.networkingSocketPeerBase).setServerVersion(BestHTTP.SocketIO.SupportedSocketIOVersions.v2);
|
|
110
|
+
}
|
|
111
|
+
else if (peerSocketVersion == PeerSocketVersion.V2_v3)
|
|
112
|
+
{
|
|
113
|
+
((NetworkingPeerSocketV2)this.networkingSocketPeerBase).setServerVersion(BestHTTP.SocketIO.SupportedSocketIOVersions.v3);
|
|
114
|
+
}
|
|
115
|
+
#endif
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
if (this.networkingSocketPeerBase == null) throw new NullReferenceException("this.networkingSocketPeerBase null");
|
|
119
|
+
|
|
120
|
+
this.networkingSocketPeerBase.init(gnServerSettings.getSocketUrl(), gnServerSettings.getReconnectDelay(), gnServerSettings.getPingInterval(), gnServerSettings.getPingTimeout());
|
|
121
|
+
this.networkingSocketPeerBase.reInitNewSocket();
|
|
122
|
+
|
|
123
|
+
this.networkingSocketPeerBase.setOnEventHandler(this.onEventHandler);
|
|
124
|
+
this.networkingSocketPeerBase.setOnResponseHandler(this.onResponseHandler);
|
|
125
|
+
|
|
126
|
+
this.subscriberServerEventHandler();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/// <summary>
|
|
130
|
+
/// Sets a callback for when the socket connects.
|
|
131
|
+
/// </summary>
|
|
132
|
+
internal void setOnConnectHandler(Action _onConnectHandler)
|
|
133
|
+
{
|
|
134
|
+
this.networkingSocketPeerBase.setOnConnectHandler(_onConnectHandler);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/// <summary>
|
|
138
|
+
/// Sets a callback for when the socket disconnects.
|
|
139
|
+
/// </summary>
|
|
140
|
+
internal void setOnDisconnectHandler(Action _onDisconnectHandler)
|
|
141
|
+
{
|
|
142
|
+
this.networkingSocketPeerBase.setOnDisconnectHandler(_onDisconnectHandler);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/// <summary>
|
|
146
|
+
/// Removes the connection callback.
|
|
147
|
+
/// </summary>
|
|
148
|
+
internal void removeOnConnectHandler(Action _onConnectHandler)
|
|
149
|
+
{
|
|
150
|
+
this.networkingSocketPeerBase.removeOnConnectHandler(_onConnectHandler);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/// <summary>
|
|
154
|
+
/// Removes the disconnection callback.
|
|
155
|
+
/// </summary>
|
|
156
|
+
internal void removeOnDisconnectHandler(Action _onDisconnectHandler)
|
|
157
|
+
{
|
|
158
|
+
this.networkingSocketPeerBase.removeOnDisconnectHandler(_onDisconnectHandler);
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/// <summary>
|
|
162
|
+
/// Connects the socket with a specified callback.
|
|
163
|
+
/// </summary>
|
|
164
|
+
internal void connect(Action _onSocketConnect)
|
|
165
|
+
{
|
|
166
|
+
this.networkingSocketPeerBase.connect(_onSocketConnect);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/// <summary>
|
|
170
|
+
/// Disconnects the socket with a specified callback.
|
|
171
|
+
/// </summary>
|
|
172
|
+
internal void disconnect(Action _onSocketDisconnect)
|
|
173
|
+
{
|
|
174
|
+
this.networkingSocketPeerBase.close(_onSocketDisconnect);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/// <summary>
|
|
178
|
+
/// Sets the event handler for incoming socket events.
|
|
179
|
+
/// </summary>
|
|
180
|
+
internal void setOnEventHandler(Action<OperationEvent> _onEventHandler)
|
|
181
|
+
{
|
|
182
|
+
this._onEventHandler = _onEventHandler;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/// <summary>
|
|
186
|
+
/// Sends an operation request via the socket.
|
|
187
|
+
/// </summary>
|
|
188
|
+
internal override void send(OperationPending operationPending)
|
|
189
|
+
{
|
|
190
|
+
base.send(operationPending);
|
|
191
|
+
|
|
192
|
+
GNDebug.log("[GN Socket SEND] " + operationPending.getOperationRequest().ToString());
|
|
193
|
+
|
|
194
|
+
var authToken = operationPending.getAuthToken();
|
|
195
|
+
var secretKey = operationPending.getSecretKey();
|
|
196
|
+
var gameId = operationPending.getGameId();
|
|
197
|
+
var customTags = operationPending.getCustomTags();
|
|
198
|
+
|
|
199
|
+
this.networkingSocketPeerBase.Send(operationPending.getRequestType(), operationPending.getRequestRole(), operationPending.getOperationRequest(), authToken, secretKey, customTags, gameId);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/// <summary>
|
|
203
|
+
/// Handles incoming socket events and invokes appropriate handlers.
|
|
204
|
+
/// </summary>
|
|
205
|
+
internal void onEventHandler(GNArray obj, bool isEncrypted)
|
|
206
|
+
{
|
|
207
|
+
var eventCode = obj.getInt(0);
|
|
208
|
+
|
|
209
|
+
var operationEvent = new OperationEvent(eventCode, obj.getGNHashtable(1));
|
|
210
|
+
operationEvent.setEncrypted(isEncrypted);
|
|
211
|
+
|
|
212
|
+
GNDebug.log("[GN Socket EVENT] " + operationEvent.toString());
|
|
213
|
+
|
|
214
|
+
this._onEventHandler?.Invoke(operationEvent);
|
|
215
|
+
|
|
216
|
+
if (!this.serverEventHandlersDict.ContainsKey(eventCode)) return;
|
|
217
|
+
|
|
218
|
+
var serverEventHandlers = this.serverEventHandlersDict[eventCode];
|
|
219
|
+
|
|
220
|
+
foreach (var serverEventHandler in serverEventHandlers)
|
|
221
|
+
serverEventHandler.handle(operationEvent);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/// <summary>
|
|
225
|
+
/// Processes socket service operations.
|
|
226
|
+
/// </summary>
|
|
227
|
+
public override void service()
|
|
228
|
+
{
|
|
229
|
+
base.service();
|
|
230
|
+
this.networkingSocketPeerBase?.service();
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
//internal static string Auth(BestHTTP.SocketIO3.SocketManager socketManager, BestHTTP.SocketIO3.Socket socket)
|
|
234
|
+
//{
|
|
235
|
+
// return authTokenFormat.Replace("$authtoken", GNNetwork.authToken);
|
|
236
|
+
//}
|
|
237
|
+
|
|
238
|
+
//internal static string Auth(BestHTTP.SocketIO.SocketManager socketManager, BestHTTP.SocketIO.Socket socket)
|
|
239
|
+
//{
|
|
240
|
+
// return authTokenFormat.Replace("$authtoken", GNNetwork.authToken);
|
|
241
|
+
//}
|
|
242
|
+
|
|
243
|
+
}
|
|
244
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 138a4e1d48a3d2f47afac60685c8f2f0
|
|
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: 138a4e1d48a3d2f47afac60685c8f2f0
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 072aeea0e87803c4cad987251dbec2f4
|
|
3
|
-
folderAsset: yes
|
|
4
|
-
DefaultImporter:
|
|
5
|
-
externalObjects: {}
|
|
6
|
-
userData:
|
|
7
|
-
assetBundleName:
|
|
8
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 072aeea0e87803c4cad987251dbec2f4
|
|
3
|
+
folderAsset: yes
|
|
4
|
+
DefaultImporter:
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
userData:
|
|
7
|
+
assetBundleName:
|
|
8
|
+
assetBundleVariant:
|
package/Runtime/Networking.meta
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 39e70e9a43268c543b8b066ca0e74205
|
|
3
|
-
folderAsset: yes
|
|
4
|
-
DefaultImporter:
|
|
5
|
-
externalObjects: {}
|
|
6
|
-
userData:
|
|
7
|
-
assetBundleName:
|
|
8
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 39e70e9a43268c543b8b066ca0e74205
|
|
3
|
+
folderAsset: yes
|
|
4
|
+
DefaultImporter:
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
userData:
|
|
7
|
+
assetBundleName:
|
|
8
|
+
assetBundleVariant:
|
|
@@ -1,20 +1,33 @@
|
|
|
1
|
-
namespace XmobiTea.GN.Unity
|
|
2
|
-
{
|
|
3
|
-
using XmobiTea.GN.Networking;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
namespace XmobiTea.GN.Unity
|
|
2
|
+
{
|
|
3
|
+
using XmobiTea.GN.Networking;
|
|
4
|
+
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// The ServiceUpdate class is responsible for updating and handling network services.
|
|
7
|
+
/// </summary>
|
|
8
|
+
internal class ServiceUpdate : UnityEngine.MonoBehaviour
|
|
9
|
+
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// The NetworkingPeer instance used to perform network operations.
|
|
12
|
+
/// </summary>
|
|
13
|
+
internal NetworkingPeer peer;
|
|
14
|
+
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// Handles the logic to update the network service.
|
|
17
|
+
/// </summary>
|
|
18
|
+
private void update()
|
|
19
|
+
{
|
|
20
|
+
// Calls the service() method of the peer object if it is not null.
|
|
21
|
+
this.peer?.service();
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/// <summary>
|
|
25
|
+
/// Unity's Update method, called once per frame.
|
|
26
|
+
/// </summary>
|
|
27
|
+
void Update()
|
|
28
|
+
{
|
|
29
|
+
// Invokes the custom update() method to handle network logic.
|
|
30
|
+
this.update();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 535d48a60a02ae14d83f19e9a749983b
|
|
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: 535d48a60a02ae14d83f19e9a749983b
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|
package/Runtime/Unity.meta
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: 58c343c317839a5469f8ff68787ae561
|
|
3
|
-
folderAsset: yes
|
|
4
|
-
DefaultImporter:
|
|
5
|
-
externalObjects: {}
|
|
6
|
-
userData:
|
|
7
|
-
assetBundleName:
|
|
8
|
-
assetBundleVariant:
|
|
1
|
+
fileFormatVersion: 2
|
|
2
|
+
guid: 58c343c317839a5469f8ff68787ae561
|
|
3
|
+
folderAsset: yes
|
|
4
|
+
DefaultImporter:
|
|
5
|
+
externalObjects: {}
|
|
6
|
+
userData:
|
|
7
|
+
assetBundleName:
|
|
8
|
+
assetBundleVariant:
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "XmobiTea.GN.runtime",
|
|
3
|
-
"rootNamespace": "",
|
|
4
|
-
"references": [
|
|
5
|
-
"BestHTTP",
|
|
6
|
-
"XmobiTea.MsgPack.runtime"
|
|
7
|
-
],
|
|
8
|
-
"includePlatforms": [],
|
|
9
|
-
"excludePlatforms": [],
|
|
10
|
-
"allowUnsafeCode": false,
|
|
11
|
-
"overrideReferences": false,
|
|
12
|
-
"precompiledReferences": [],
|
|
13
|
-
"autoReferenced": true,
|
|
14
|
-
"defineConstraints": [],
|
|
15
|
-
"versionDefines": [],
|
|
16
|
-
"noEngineReferences": false
|
|
1
|
+
{
|
|
2
|
+
"name": "XmobiTea.GN.runtime",
|
|
3
|
+
"rootNamespace": "",
|
|
4
|
+
"references": [
|
|
5
|
+
"BestHTTP",
|
|
6
|
+
"XmobiTea.MsgPack.runtime"
|
|
7
|
+
],
|
|
8
|
+
"includePlatforms": [],
|
|
9
|
+
"excludePlatforms": [],
|
|
10
|
+
"allowUnsafeCode": false,
|
|
11
|
+
"overrideReferences": false,
|
|
12
|
+
"precompiledReferences": [],
|
|
13
|
+
"autoReferenced": true,
|
|
14
|
+
"defineConstraints": [],
|
|
15
|
+
"versionDefines": [],
|
|
16
|
+
"noEngineReferences": false
|
|
17
17
|
}
|