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
|
@@ -9,18 +9,42 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
9
9
|
using XmobiTea.GN.Logger;
|
|
10
10
|
using XmobiTea.MsgPack;
|
|
11
11
|
|
|
12
|
+
/// <summary>
|
|
13
|
+
/// Represents a socket packet containing data and encryption information.
|
|
14
|
+
/// </summary>
|
|
12
15
|
public class SocketPacket
|
|
13
16
|
{
|
|
17
|
+
/// <summary>
|
|
18
|
+
/// Gets the byte array of the packet data.
|
|
19
|
+
/// </summary>
|
|
14
20
|
public byte[] byteArr { get; private set; }
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
/// Indicates whether the packet is encrypted.
|
|
24
|
+
/// </summary>
|
|
15
25
|
public bool encrypted { get; private set; }
|
|
26
|
+
|
|
27
|
+
/// <summary>
|
|
28
|
+
/// Gets the object data of the packet.
|
|
29
|
+
/// </summary>
|
|
16
30
|
public object obj { get; private set; }
|
|
17
31
|
|
|
32
|
+
/// <summary>
|
|
33
|
+
/// Initializes a new instance of the <see cref="SocketPacket"/> class with byte array data.
|
|
34
|
+
/// </summary>
|
|
35
|
+
/// <param name="byteArr">The byte array of the packet.</param>
|
|
36
|
+
/// <param name="encrypted">Indicates whether the packet is encrypted.</param>
|
|
18
37
|
public SocketPacket(byte[] byteArr, bool encrypted)
|
|
19
38
|
{
|
|
20
39
|
this.byteArr = byteArr;
|
|
21
40
|
this.encrypted = encrypted;
|
|
22
41
|
}
|
|
23
42
|
|
|
43
|
+
/// <summary>
|
|
44
|
+
/// Initializes a new instance of the <see cref="SocketPacket"/> class with object data.
|
|
45
|
+
/// </summary>
|
|
46
|
+
/// <param name="obj">The object data of the packet.</param>
|
|
47
|
+
/// <param name="encrypted">Indicates whether the packet is encrypted.</param>
|
|
24
48
|
public SocketPacket(object obj, bool encrypted)
|
|
25
49
|
{
|
|
26
50
|
this.obj = obj;
|
|
@@ -28,51 +52,92 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
28
52
|
}
|
|
29
53
|
}
|
|
30
54
|
|
|
55
|
+
/// <summary>
|
|
56
|
+
/// Base class for managing socket peer connections.
|
|
57
|
+
/// </summary>
|
|
31
58
|
public abstract class NetworkingSocketPeerBase
|
|
32
59
|
{
|
|
33
60
|
#region Public Properties
|
|
34
61
|
|
|
62
|
+
/// <summary>
|
|
63
|
+
/// The delay between reconnection attempts, in milliseconds.
|
|
64
|
+
/// </summary>
|
|
35
65
|
protected internal int reconnectDelay;
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
/// The interval for ping messages, in seconds.
|
|
69
|
+
/// </summary>
|
|
36
70
|
protected internal float pingInterval;
|
|
71
|
+
|
|
72
|
+
/// <summary>
|
|
73
|
+
/// The timeout for ping messages, in seconds.
|
|
74
|
+
/// </summary>
|
|
37
75
|
protected internal float pingTimeout;
|
|
38
76
|
|
|
77
|
+
/// <summary>
|
|
78
|
+
/// Gets or sets the client ID for the connection.
|
|
79
|
+
/// </summary>
|
|
39
80
|
internal string clientId { get; set; }
|
|
81
|
+
|
|
82
|
+
/// <summary>
|
|
83
|
+
/// Gets whether the WebSocket connection is open.
|
|
84
|
+
/// </summary>
|
|
40
85
|
internal virtual bool isWsConnected { get; private set; }
|
|
41
86
|
|
|
87
|
+
/// <summary>
|
|
88
|
+
/// Lock object for message lists.
|
|
89
|
+
/// </summary>
|
|
42
90
|
protected internal object messageLstLock;
|
|
91
|
+
|
|
92
|
+
/// <summary>
|
|
93
|
+
/// List of response packets.
|
|
94
|
+
/// </summary>
|
|
43
95
|
protected internal List<SocketPacket> responsePacketLst;
|
|
96
|
+
|
|
97
|
+
/// <summary>
|
|
98
|
+
/// List of event packets.
|
|
99
|
+
/// </summary>
|
|
44
100
|
protected internal List<SocketPacket> eventPacketLst;
|
|
45
101
|
|
|
46
102
|
#endregion
|
|
47
103
|
|
|
48
104
|
#region Private Properties
|
|
49
105
|
|
|
106
|
+
/// <summary>
|
|
107
|
+
/// The server URL.
|
|
108
|
+
/// </summary>
|
|
50
109
|
protected string url;
|
|
51
110
|
|
|
52
111
|
private Action<GNArray, bool> _onEventHandler;
|
|
53
112
|
private Action<GNArray, bool> _onResponseHandler;
|
|
54
|
-
|
|
55
113
|
private Action _onSocketConnect;
|
|
56
114
|
private Action _onSocketDisconnect;
|
|
57
|
-
|
|
58
115
|
private Action _onConnectHandler;
|
|
59
116
|
private Action _onDisconnectHandler;
|
|
60
117
|
|
|
61
118
|
#endregion
|
|
62
119
|
|
|
120
|
+
/// <summary>
|
|
121
|
+
/// Initializes the socket peer with the specified settings.
|
|
122
|
+
/// </summary>
|
|
123
|
+
/// <param name="url">The server URL.</param>
|
|
124
|
+
/// <param name="reconnectDelay">Delay in milliseconds before reconnect attempts.</param>
|
|
125
|
+
/// <param name="pingInterval">Ping interval in seconds.</param>
|
|
126
|
+
/// <param name="pingTimeout">Ping timeout in seconds.</param>
|
|
63
127
|
internal virtual void init(string url, int reconnectDelay, float pingInterval, float pingTimeout)
|
|
64
128
|
{
|
|
65
129
|
this.url = url;
|
|
66
|
-
|
|
67
130
|
this.reconnectDelay = reconnectDelay;
|
|
68
131
|
this.pingInterval = pingInterval;
|
|
69
132
|
this.pingTimeout = pingTimeout;
|
|
70
133
|
}
|
|
71
134
|
|
|
135
|
+
/// <summary>
|
|
136
|
+
/// Constructor for initializing the NetworkingSocketPeerBase class.
|
|
137
|
+
/// </summary>
|
|
72
138
|
public NetworkingSocketPeerBase()
|
|
73
139
|
{
|
|
74
140
|
this.clientId = string.Empty;
|
|
75
|
-
|
|
76
141
|
this.messageLstLock = new object();
|
|
77
142
|
this.responsePacketLst = new List<SocketPacket>();
|
|
78
143
|
this.eventPacketLst = new List<SocketPacket>();
|
|
@@ -80,59 +145,98 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
80
145
|
|
|
81
146
|
#region Public Interface
|
|
82
147
|
|
|
148
|
+
/// <summary>
|
|
149
|
+
/// Connects to the socket server.
|
|
150
|
+
/// </summary>
|
|
151
|
+
/// <param name="_onSocketConnect">Callback invoked upon successful connection.</param>
|
|
83
152
|
internal virtual void connect(Action _onSocketConnect)
|
|
84
153
|
{
|
|
85
154
|
this._onSocketConnect = _onSocketConnect;
|
|
86
155
|
}
|
|
87
156
|
|
|
157
|
+
/// <summary>
|
|
158
|
+
/// Closes the socket connection.
|
|
159
|
+
/// </summary>
|
|
160
|
+
/// <param name="_onSocketDisconnect">Callback invoked upon disconnection.</param>
|
|
88
161
|
internal virtual void close(Action _onSocketDisconnect)
|
|
89
162
|
{
|
|
90
163
|
this._onSocketDisconnect = _onSocketDisconnect;
|
|
91
164
|
}
|
|
92
165
|
|
|
93
|
-
|
|
166
|
+
/// <summary>
|
|
167
|
+
/// Sends an authentication request via the socket.
|
|
168
|
+
/// </summary>
|
|
169
|
+
internal virtual void sendRequestAuthSocket() { }
|
|
170
|
+
|
|
171
|
+
/// <summary>
|
|
172
|
+
/// Sends a request via the socket.
|
|
173
|
+
/// </summary>
|
|
174
|
+
/// <param name="requestType">The type of the request.</param>
|
|
175
|
+
/// <param name="requestRole">The role of the request.</param>
|
|
176
|
+
/// <param name="operationRequest">The operation request object.</param>
|
|
177
|
+
/// <param name="authToken">Authentication token, if applicable.</param>
|
|
178
|
+
/// <param name="secretKey">Secret key, if applicable.</param>
|
|
179
|
+
/// <param name="customTags">Custom tags for the request.</param>
|
|
180
|
+
internal void Send(RequestType requestType, RequestRole requestRole, OperationRequest operationRequest, string authToken, string secretKey, GNHashtable customTags, string gameId)
|
|
94
181
|
{
|
|
95
|
-
|
|
182
|
+
this.emit(requestType, requestRole, operationRequest, authToken, secretKey, customTags, gameId);
|
|
96
183
|
}
|
|
97
184
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
protected virtual void emit(RequestType requestType, RequestRole requestRole, OperationRequest operationRequest, string authToken, string secretKey, GNHashtable customTags) { }
|
|
185
|
+
/// <summary>
|
|
186
|
+
/// Emits a request to the socket.
|
|
187
|
+
/// </summary>
|
|
188
|
+
protected virtual void emit(RequestType requestType, RequestRole requestRole, OperationRequest operationRequest, string authToken, string secretKey, GNHashtable customTags, string gameId) { }
|
|
104
189
|
|
|
105
190
|
#endregion
|
|
106
191
|
|
|
107
192
|
#region Private Methods
|
|
108
193
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
194
|
+
/// <summary>
|
|
195
|
+
/// Reinitializes the socket connection with a new configuration.
|
|
196
|
+
/// </summary>
|
|
197
|
+
internal virtual void reInitNewSocket() { }
|
|
113
198
|
|
|
199
|
+
/// <summary>
|
|
200
|
+
/// Sets the callback to be invoked when the socket connects.
|
|
201
|
+
/// </summary>
|
|
202
|
+
/// <param name="_onConnectHandler">The callback action.</param>
|
|
114
203
|
internal void setOnConnectHandler(Action _onConnectHandler)
|
|
115
204
|
{
|
|
116
205
|
this._onConnectHandler -= _onConnectHandler;
|
|
117
206
|
this._onConnectHandler += _onConnectHandler;
|
|
118
207
|
}
|
|
119
208
|
|
|
209
|
+
/// <summary>
|
|
210
|
+
/// Sets the callback to be invoked when the socket disconnects.
|
|
211
|
+
/// </summary>
|
|
212
|
+
/// <param name="_onDisconnectHandler">The callback action.</param>
|
|
120
213
|
internal void setOnDisconnectHandler(Action _onDisconnectHandler)
|
|
121
214
|
{
|
|
122
215
|
this._onDisconnectHandler -= _onDisconnectHandler;
|
|
123
216
|
this._onDisconnectHandler += _onDisconnectHandler;
|
|
124
217
|
}
|
|
125
218
|
|
|
219
|
+
/// <summary>
|
|
220
|
+
/// Removes the specified callback for socket connection events.
|
|
221
|
+
/// </summary>
|
|
222
|
+
/// <param name="_onConnectHandler">The callback action to remove.</param>
|
|
126
223
|
internal void removeOnConnectHandler(Action _onConnectHandler)
|
|
127
224
|
{
|
|
128
225
|
this._onConnectHandler -= _onConnectHandler;
|
|
129
226
|
}
|
|
130
227
|
|
|
228
|
+
/// <summary>
|
|
229
|
+
/// Removes the specified callback for socket disconnection events.
|
|
230
|
+
/// </summary>
|
|
231
|
+
/// <param name="_onDisconnectHandler">The callback action to remove.</param>
|
|
131
232
|
internal void removeOnDisconnectHandler(Action _onDisconnectHandler)
|
|
132
233
|
{
|
|
133
234
|
this._onDisconnectHandler -= _onDisconnectHandler;
|
|
134
235
|
}
|
|
135
236
|
|
|
237
|
+
/// <summary>
|
|
238
|
+
/// Invokes the connection handler and sends an authentication request if applicable.
|
|
239
|
+
/// </summary>
|
|
136
240
|
internal void onConnectHandler()
|
|
137
241
|
{
|
|
138
242
|
this._onConnectHandler?.Invoke();
|
|
@@ -147,34 +251,58 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
147
251
|
this._onSocketConnect = null;
|
|
148
252
|
}
|
|
149
253
|
|
|
254
|
+
/// <summary>
|
|
255
|
+
/// Invokes the disconnection handler and cleans up associated resources.
|
|
256
|
+
/// </summary>
|
|
150
257
|
internal void onDisconnectHandler()
|
|
151
258
|
{
|
|
152
259
|
this._onDisconnectHandler?.Invoke();
|
|
153
|
-
|
|
154
260
|
this._onSocketDisconnect?.Invoke();
|
|
155
261
|
this._onSocketDisconnect = null;
|
|
156
262
|
}
|
|
157
263
|
|
|
264
|
+
/// <summary>
|
|
265
|
+
/// Sets the handler for processing socket events.
|
|
266
|
+
/// </summary>
|
|
267
|
+
/// <param name="_onEventHandler">The event handler action.</param>
|
|
158
268
|
internal void setOnEventHandler(Action<GNArray, bool> _onEventHandler)
|
|
159
269
|
{
|
|
160
270
|
this._onEventHandler = _onEventHandler;
|
|
161
271
|
}
|
|
162
272
|
|
|
273
|
+
/// <summary>
|
|
274
|
+
/// Invokes the event handler with the specified data and encryption status.
|
|
275
|
+
/// </summary>
|
|
276
|
+
/// <param name="obj">The event data.</param>
|
|
277
|
+
/// <param name="isEncrypted">Indicates whether the data is encrypted.</param>
|
|
163
278
|
internal void onEventHandler(GNArray obj, bool isEncrypted)
|
|
164
279
|
{
|
|
165
280
|
this._onEventHandler?.Invoke(obj, isEncrypted);
|
|
166
281
|
}
|
|
167
282
|
|
|
283
|
+
/// <summary>
|
|
284
|
+
/// Sets the handler for processing socket responses.
|
|
285
|
+
/// </summary>
|
|
286
|
+
/// <param name="_onResponseHandler">The response handler action.</param>
|
|
168
287
|
internal void setOnResponseHandler(Action<GNArray, bool> _onResponseHandler)
|
|
169
288
|
{
|
|
170
289
|
this._onResponseHandler = _onResponseHandler;
|
|
171
290
|
}
|
|
172
291
|
|
|
292
|
+
/// <summary>
|
|
293
|
+
/// Invokes the response handler with the specified data and encryption status.
|
|
294
|
+
/// </summary>
|
|
295
|
+
/// <param name="obj">The response data.</param>
|
|
296
|
+
/// <param name="isEncrypted">Indicates whether the data is encrypted.</param>
|
|
173
297
|
internal void onResponseHandler(GNArray obj, bool isEncrypted)
|
|
174
298
|
{
|
|
175
299
|
this._onResponseHandler?.Invoke(obj, isEncrypted);
|
|
176
300
|
}
|
|
177
|
-
|
|
301
|
+
/// <summary>
|
|
302
|
+
/// Converts an array of key-value pairs to a dictionary.
|
|
303
|
+
/// </summary>
|
|
304
|
+
/// <param name="keyValuePairs">The array of key-value pairs to convert.</param>
|
|
305
|
+
/// <returns>A dictionary representing the key-value pairs.</returns>
|
|
178
306
|
internal static System.Collections.IDictionary fromMsgKeyValuePairs(KeyValuePair<object, object>[] keyValuePairs)
|
|
179
307
|
{
|
|
180
308
|
var answer = new Dictionary<object, object>();
|
|
@@ -203,6 +331,11 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
203
331
|
return answer;
|
|
204
332
|
}
|
|
205
333
|
|
|
334
|
+
/// <summary>
|
|
335
|
+
/// Converts an array of objects to a list.
|
|
336
|
+
/// </summary>
|
|
337
|
+
/// <param name="objects">The array of objects to convert.</param>
|
|
338
|
+
/// <returns>A list representing the objects.</returns>
|
|
206
339
|
internal static System.Collections.IList fromMsgList(object[] objects)
|
|
207
340
|
{
|
|
208
341
|
var answer = new List<object>();
|
|
@@ -228,15 +361,24 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
228
361
|
return answer;
|
|
229
362
|
}
|
|
230
363
|
|
|
364
|
+
/// <summary>
|
|
365
|
+
/// Converts a JSON object to a list.
|
|
366
|
+
/// </summary>
|
|
367
|
+
/// <param name="objects">The JSON object to convert.</param>
|
|
368
|
+
/// <returns>A list representing the JSON object.</returns>
|
|
231
369
|
internal static System.Collections.IList fromJsonList(object objects)
|
|
232
370
|
{
|
|
233
371
|
return (System.Collections.IList)objects;
|
|
234
372
|
}
|
|
235
373
|
|
|
374
|
+
/// <summary>
|
|
375
|
+
/// Processes incoming response and event packets.
|
|
376
|
+
/// </summary>
|
|
236
377
|
internal void service()
|
|
237
378
|
{
|
|
238
379
|
lock (this.messageLstLock)
|
|
239
380
|
{
|
|
381
|
+
// Process response packets
|
|
240
382
|
if (this.responsePacketLst.Count > 0)
|
|
241
383
|
{
|
|
242
384
|
for (var i = 0; i < this.responsePacketLst.Count; i++)
|
|
@@ -254,7 +396,7 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
254
396
|
var gnArray = new GNArray.Builder()
|
|
255
397
|
.addAll(NetworkingSocketPeerBase.fromMsgList(iList))
|
|
256
398
|
.build();
|
|
257
|
-
onResponseHandler(gnArray, responsePacket.encrypted);
|
|
399
|
+
this.onResponseHandler(gnArray, responsePacket.encrypted);
|
|
258
400
|
}
|
|
259
401
|
catch (Exception ex)
|
|
260
402
|
{
|
|
@@ -270,7 +412,7 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
270
412
|
var gnArray = new GNArray.Builder()
|
|
271
413
|
.addAll(NetworkingSocketPeerBase.fromJsonList(iList))
|
|
272
414
|
.build();
|
|
273
|
-
onResponseHandler(gnArray, responsePacket.encrypted);
|
|
415
|
+
this.onResponseHandler(gnArray, responsePacket.encrypted);
|
|
274
416
|
}
|
|
275
417
|
catch (Exception ex)
|
|
276
418
|
{
|
|
@@ -282,6 +424,7 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
282
424
|
this.responsePacketLst.Clear();
|
|
283
425
|
}
|
|
284
426
|
|
|
427
|
+
// Process event packets
|
|
285
428
|
if (this.eventPacketLst.Count > 0)
|
|
286
429
|
{
|
|
287
430
|
for (var i = 0; i < this.eventPacketLst.Count; i++)
|
|
@@ -299,7 +442,7 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
299
442
|
var gnArray = new GNArray.Builder()
|
|
300
443
|
.addAll(NetworkingSocketPeerBase.fromMsgList(iList))
|
|
301
444
|
.build();
|
|
302
|
-
onEventHandler(gnArray, eventPacket.encrypted);
|
|
445
|
+
this.onEventHandler(gnArray, eventPacket.encrypted);
|
|
303
446
|
}
|
|
304
447
|
catch (Exception ex)
|
|
305
448
|
{
|
|
@@ -315,7 +458,7 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
315
458
|
var gnArray = new GNArray.Builder()
|
|
316
459
|
.addAll(NetworkingSocketPeerBase.fromJsonList(iList))
|
|
317
460
|
.build();
|
|
318
|
-
onEventHandler(gnArray, eventPacket.encrypted);
|
|
461
|
+
this.onEventHandler(gnArray, eventPacket.encrypted);
|
|
319
462
|
}
|
|
320
463
|
catch (Exception ex)
|
|
321
464
|
{
|
|
@@ -331,5 +474,4 @@ namespace XmobiTea.GN.Networking.Socket
|
|
|
331
474
|
|
|
332
475
|
#endregion
|
|
333
476
|
}
|
|
334
|
-
|
|
335
477
|
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
fileFormatVersion: 2
|
|
2
|
-
guid: e7f2b95d6b7d58a4d92fce79cd93f5b7
|
|
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: e7f2b95d6b7d58a4d92fce79cd93f5b7
|
|
3
|
+
MonoImporter:
|
|
4
|
+
externalObjects: {}
|
|
5
|
+
serializedVersion: 2
|
|
6
|
+
defaultReferences: []
|
|
7
|
+
executionOrder: 0
|
|
8
|
+
icon: {instanceID: 0}
|
|
9
|
+
userData:
|
|
10
|
+
assetBundleName:
|
|
11
|
+
assetBundleVariant:
|