com.xmobitea.changx.gn-unity 2.0.2 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Editor/GNServerSettingsEditor.cs +42 -322
- package/Runtime/Common/GNArray.cs +120 -35
- package/Runtime/Common/GNData.cs +19 -6
- package/Runtime/Common/GNHashtable.cs +174 -11
- package/Runtime/Common/IGNData.cs +11 -2
- package/Runtime/Config/GNServerSettings.cs +136 -92
- package/Runtime/Constant/Commands.cs +82 -19
- package/Runtime/Constant/EnumType/GoogleLoginType.cs +5 -5
- package/Runtime/Constant/EnumType/GroupStatus.cs +7 -7
- package/Runtime/Constant/EnumType/ItemType.cs +5 -5
- package/Runtime/Constant/EnumType/MatchmakingMemberStatus.cs +6 -6
- package/Runtime/Constant/EnumType/MatchmakingTicketStatus.cs +2 -2
- package/Runtime/Constant/EnumType/OwnerType.cs +3 -2
- package/Runtime/Constant/EnumType/PushPlatformType.cs +10 -0
- package/Runtime/Constant/EnumType/PushPlatformType.cs.meta +11 -0
- package/Runtime/Constant/EnumType/RequestType.cs +1 -0
- package/Runtime/Constant/EnumType/StoreReceiveType.cs +13 -0
- package/Runtime/Constant/EnumType/StoreReceiveType.cs.meta +11 -0
- package/Runtime/Constant/ErrorCode/GNErrorCode.cs +53 -48
- package/Runtime/Constant/EventCode.cs +29 -2
- package/Runtime/Constant/OperationCode.cs +249 -211
- package/Runtime/Constant/ParameterCode/GNParameterCode.cs +610 -466
- package/Runtime/Constant/ReturnCode.cs +50 -2
- package/Runtime/Entity/DataMember.cs +221 -3
- package/Runtime/Entity/GNMetadata.cs +46 -1
- package/Runtime/Entity/InvalidMember.cs +24 -5
- package/Runtime/Entity/Models/AuthenticateModels.cs +251 -207
- package/Runtime/Entity/Models/AuthenticateRequestModels.cs +153 -131
- package/Runtime/Entity/Models/AuthenticateResponseModels.cs +61 -51
- package/Runtime/Entity/Models/CharacterPlayerModels.cs +985 -849
- package/Runtime/Entity/Models/CharacterPlayerRequestModels.cs +957 -885
- package/Runtime/Entity/Models/CharacterPlayerResponseModels.cs +165 -150
- package/Runtime/Entity/Models/CloudScriptModels.cs +185 -0
- package/Runtime/Entity/Models/CloudScriptModels.cs.meta +11 -0
- package/Runtime/Entity/Models/CloudScriptRequestModels.cs +134 -0
- package/Runtime/Entity/Models/CloudScriptRequestModels.cs.meta +11 -0
- package/Runtime/Entity/Models/CloudScriptResponseModels.cs +34 -0
- package/Runtime/Entity/Models/CloudScriptResponseModels.cs.meta +11 -0
- package/Runtime/Entity/Models/ContentModels.cs +150 -153
- package/Runtime/Entity/Models/ContentRequestModels.cs +129 -129
- package/Runtime/Entity/Models/ContentResponseModels.cs +24 -24
- package/Runtime/Entity/Models/DashboardModels.cs +1684 -1156
- package/Runtime/Entity/Models/DashboardRequestModels.cs +220 -147
- package/Runtime/Entity/Models/DashboardResponseModels.cs +92 -57
- package/Runtime/Entity/Models/GamePlayerModels.cs +1073 -933
- package/Runtime/Entity/Models/GamePlayerRequestModels.cs +939 -867
- package/Runtime/Entity/Models/GamePlayerResponseModels.cs +162 -147
- package/Runtime/Entity/Models/GenericModels.cs +102 -102
- package/Runtime/Entity/Models/GroupModels.cs +812 -676
- package/Runtime/Entity/Models/GroupRequestModels.cs +741 -669
- package/Runtime/Entity/Models/GroupResponseModels.cs +129 -114
- package/Runtime/Entity/Models/InventoryModels.cs +667 -558
- package/Runtime/Entity/Models/InventoryRequestModels.cs +626 -579
- package/Runtime/Entity/Models/InventoryResponseModels.cs +109 -99
- package/Runtime/Entity/Models/MasterPlayerModels.cs +1882 -1340
- package/Runtime/Entity/Models/MasterPlayerRequestModels.cs +1643 -1253
- package/Runtime/Entity/Models/MasterPlayerResponseModels.cs +293 -213
- package/Runtime/Entity/Models/MultiplayerModels.cs +293 -223
- package/Runtime/Entity/Models/MultiplayerRequestModels.cs +199 -149
- package/Runtime/Entity/Models/MultiplayerResponseModels.cs +10 -0
- package/Runtime/Entity/Models/StoreInventoryModels.cs +514 -323
- package/Runtime/Entity/Models/StoreInventoryRequestModels.cs +236 -165
- package/Runtime/Entity/Models/StoreInventoryResponseModels.cs +45 -30
- package/Runtime/Entity/OperationEvent.cs +43 -7
- package/Runtime/Entity/OperationHelper.cs +18 -2
- package/Runtime/Entity/OperationRequest.cs +80 -37
- package/Runtime/Entity/OperationResponse.cs +111 -63
- package/Runtime/Entity/Request/CustomOperationRequest.cs +53 -2
- package/Runtime/Entity/Response/CustomOperationResponse.cs +25 -4
- package/Runtime/GNNetwork.cs +333 -21
- package/Runtime/GNNetworkApi.cs +25 -13
- package/Runtime/GNNetworkAuthenticateApi.cs +531 -98
- package/Runtime/GNNetworkCharacterPlayerApi.cs +1587 -762
- package/Runtime/GNNetworkCloudScriptApi.cs +181 -0
- package/Runtime/GNNetworkCloudScriptApi.cs.meta +11 -0
- package/Runtime/GNNetworkContentApi.cs +238 -132
- package/Runtime/GNNetworkDashboardApi.cs +278 -117
- package/Runtime/GNNetworkGamePlayerApi.cs +1558 -747
- package/Runtime/GNNetworkGroupApi.cs +1228 -582
- package/Runtime/GNNetworkInventoryApi.cs +1048 -507
- package/Runtime/GNNetworkMasterPlayerApi.cs +2586 -1067
- package/Runtime/GNNetworkMultiplayerApi.cs +328 -147
- package/Runtime/GNNetworkStoreInventoryApi.cs +388 -162
- package/Runtime/Helper/CodeHelper.cs +45 -3
- package/Runtime/Helper/ConverterService.cs +240 -85
- package/Runtime/Logger/GNDebug.cs +46 -3
- package/Runtime/Networking/AuthenticateStatus.cs +30 -8
- package/Runtime/Networking/Handler/IServerEventHandler.cs +8 -8
- package/Runtime/Networking/Handler/OnCharacterPlayerFriendUpdateEventHandler.cs +31 -2
- package/Runtime/Networking/Handler/OnCharacterPlayerGroupUpdateEventHandler.cs +24 -3
- package/Runtime/Networking/Handler/OnGamePlayerFriendUpdateEventHandler.cs +24 -2
- package/Runtime/Networking/Handler/OnGamePlayerGroupUpdateEventHandler.cs +24 -2
- package/Runtime/Networking/Handler/OnGroupMemberUpdateEventHandler.cs +21 -2
- package/Runtime/Networking/Handler/OnGroupMessageUpdateEventHandler.cs +20 -2
- package/Runtime/Networking/Http/HttpPeer.cs +68 -25
- package/Runtime/Networking/Http/NetworkingHttpPeerBase.cs +44 -4
- package/Runtime/Networking/Http/NetworkingPeerHttpClientRequest.cs +63 -40
- package/Runtime/Networking/Http/NetworkingPeerHttpRequest.cs +43 -13
- package/Runtime/Networking/Http/NetworkingPeerUnityWebRequest.cs +72 -39
- package/Runtime/Networking/IPeer.cs +24 -2
- package/Runtime/Networking/NetworkingPeer.cs +64 -10
- package/Runtime/Networking/NetworkingPeerAPI.cs +20 -21
- package/Runtime/Networking/OperationPending.cs +79 -15
- package/Runtime/Networking/PeerBase.cs +86 -23
- package/Runtime/Networking/Socket/NetworkingPeerSocketV2.cs +57 -18
- package/Runtime/Networking/Socket/NetworkingPeerSocketV3.cs +70 -10
- package/Runtime/Networking/Socket/NetworkingSocketPeerBase.cs +165 -23
- package/Runtime/Networking/Socket/SocketPeer.cs +63 -12
- package/Runtime/Unity/ServiceCoroutine.cs +10 -0
- package/Runtime/Unity/ServiceCoroutine.cs.meta +11 -0
- package/Runtime/Unity/ServiceUpdate.cs +14 -1
- package/package.json +1 -1
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
namespace XmobiTea.GN.Entity
|
|
2
2
|
{
|
|
3
3
|
using System.Text;
|
|
4
|
-
|
|
5
4
|
using XmobiTea.GN.Common;
|
|
6
5
|
using XmobiTea.GN.Helper;
|
|
7
6
|
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Represents an operation event with a code, parameters, and encryption status.
|
|
9
|
+
/// </summary>
|
|
8
10
|
public class OperationEvent
|
|
9
11
|
{
|
|
10
|
-
|
|
11
12
|
private int eventCode;
|
|
12
13
|
private GNHashtable parameters;
|
|
13
14
|
private bool encrypted;
|
|
14
15
|
|
|
16
|
+
/// <summary>
|
|
17
|
+
/// Initializes a new instance of the <see cref="OperationEvent"/> class.
|
|
18
|
+
/// </summary>
|
|
19
|
+
/// <param name="eventCode">The event code.</param>
|
|
20
|
+
/// <param name="parameters">Optional parameters associated with the event.</param>
|
|
21
|
+
/// <param name="encrypted">Whether the event is encrypted.</param>
|
|
15
22
|
public OperationEvent(int eventCode, GNHashtable parameters = null, bool encrypted = true)
|
|
16
23
|
{
|
|
17
24
|
this.eventCode = eventCode;
|
|
@@ -19,21 +26,36 @@
|
|
|
19
26
|
this.encrypted = encrypted;
|
|
20
27
|
}
|
|
21
28
|
|
|
29
|
+
/// <summary>
|
|
30
|
+
/// Gets the event code.
|
|
31
|
+
/// </summary>
|
|
22
32
|
public int getEventCode()
|
|
23
33
|
{
|
|
24
34
|
return this.eventCode;
|
|
25
35
|
}
|
|
26
36
|
|
|
37
|
+
/// <summary>
|
|
38
|
+
/// Gets the parameters associated with the event.
|
|
39
|
+
/// </summary>
|
|
27
40
|
public GNHashtable getParameters()
|
|
28
41
|
{
|
|
29
42
|
return this.parameters;
|
|
30
43
|
}
|
|
31
44
|
|
|
45
|
+
/// <summary>
|
|
46
|
+
/// Determines if the event is encrypted.
|
|
47
|
+
/// </summary>
|
|
32
48
|
public bool isEncrypted()
|
|
33
49
|
{
|
|
34
50
|
return this.encrypted;
|
|
35
51
|
}
|
|
36
52
|
|
|
53
|
+
/// <summary>
|
|
54
|
+
/// Sets a parameter for the event.
|
|
55
|
+
/// </summary>
|
|
56
|
+
/// <param name="key">The parameter key.</param>
|
|
57
|
+
/// <param name="value">The parameter value.</param>
|
|
58
|
+
/// <returns>The updated <see cref="OperationEvent"/>.</returns>
|
|
37
59
|
public OperationEvent setParameter(string key, object value)
|
|
38
60
|
{
|
|
39
61
|
if (this.parameters == null) this.parameters = new GNHashtable();
|
|
@@ -43,6 +65,11 @@
|
|
|
43
65
|
return this;
|
|
44
66
|
}
|
|
45
67
|
|
|
68
|
+
/// <summary>
|
|
69
|
+
/// Sets the parameters for the event.
|
|
70
|
+
/// </summary>
|
|
71
|
+
/// <param name="parameters">The parameters to set.</param>
|
|
72
|
+
/// <returns>The updated <see cref="OperationEvent"/>.</returns>
|
|
46
73
|
public OperationEvent setParameters(GNHashtable parameters)
|
|
47
74
|
{
|
|
48
75
|
this.parameters = parameters;
|
|
@@ -50,26 +77,35 @@
|
|
|
50
77
|
return this;
|
|
51
78
|
}
|
|
52
79
|
|
|
80
|
+
/// <summary>
|
|
81
|
+
/// Sets the encryption status of the event.
|
|
82
|
+
/// </summary>
|
|
83
|
+
/// <param name="encrypted">Whether the event is encrypted.</param>
|
|
84
|
+
/// <returns>The updated <see cref="OperationEvent"/>.</returns>
|
|
53
85
|
public OperationEvent setEncrypted(bool encrypted)
|
|
54
86
|
{
|
|
55
87
|
this.encrypted = encrypted;
|
|
56
88
|
return this;
|
|
57
89
|
}
|
|
58
90
|
|
|
91
|
+
/// <summary>
|
|
92
|
+
/// Converts the operation event to a string representation.
|
|
93
|
+
/// </summary>
|
|
94
|
+
/// <returns>A string describing the operation event.</returns>
|
|
59
95
|
public string toString()
|
|
60
96
|
{
|
|
61
97
|
var stringBuilder = new StringBuilder();
|
|
62
|
-
|
|
63
|
-
stringBuilder.Append("Code: " + CodeHelper.getEventCodeName(this.eventCode) + ", parameters " + this.parameters + ", encrypted " + this.encrypted);
|
|
64
|
-
|
|
98
|
+
stringBuilder.Append("Code: " + CodeHelper.getEventCodeName(this.eventCode) + ", parameters: " + this.parameters + ", encrypted: " + this.encrypted);
|
|
65
99
|
return stringBuilder.ToString();
|
|
66
100
|
}
|
|
67
101
|
|
|
102
|
+
/// <summary>
|
|
103
|
+
/// Overrides the default ToString method.
|
|
104
|
+
/// </summary>
|
|
105
|
+
/// <returns>A string describing the operation event.</returns>
|
|
68
106
|
public override string ToString()
|
|
69
107
|
{
|
|
70
108
|
return this.toString();
|
|
71
109
|
}
|
|
72
|
-
|
|
73
110
|
}
|
|
74
|
-
|
|
75
111
|
}
|
|
@@ -2,8 +2,18 @@ using XmobiTea.GN.Constant;
|
|
|
2
2
|
|
|
3
3
|
namespace XmobiTea.GN.Entity
|
|
4
4
|
{
|
|
5
|
+
/// <summary>
|
|
6
|
+
/// Utility class for handling operations and formatting data for socket or HTTP communication.
|
|
7
|
+
/// </summary>
|
|
5
8
|
public class OperationHelper
|
|
6
9
|
{
|
|
10
|
+
/// <summary>
|
|
11
|
+
/// Converts an operation request to a format suitable for socket transmission.
|
|
12
|
+
/// </summary>
|
|
13
|
+
/// <param name="requestType">The type of the request (e.g., command, query).</param>
|
|
14
|
+
/// <param name="requestRole">The role of the request (e.g., client, admin).</param>
|
|
15
|
+
/// <param name="request">The operation request to be formatted.</param>
|
|
16
|
+
/// <returns>A formatted object array ready for socket transmission.</returns>
|
|
7
17
|
public static object toSocketData(RequestType requestType, RequestRole requestRole, OperationRequest request)
|
|
8
18
|
{
|
|
9
19
|
var requestId = request.getRequestId();
|
|
@@ -25,11 +35,17 @@ namespace XmobiTea.GN.Entity
|
|
|
25
35
|
};
|
|
26
36
|
}
|
|
27
37
|
|
|
38
|
+
/// <summary>
|
|
39
|
+
/// Converts an operation request to a format suitable for HTTP transmission.
|
|
40
|
+
/// </summary>
|
|
41
|
+
/// <param name="requestType">The type of the request (e.g., command, query).</param>
|
|
42
|
+
/// <param name="requestRole">The role of the request (e.g., client, admin).</param>
|
|
43
|
+
/// <param name="request">The operation request to be formatted.</param>
|
|
44
|
+
/// <returns>A formatted object representing the HTTP request data.</returns>
|
|
28
45
|
public static object toHttpData(RequestType requestType, RequestRole requestRole, OperationRequest request)
|
|
29
46
|
{
|
|
47
|
+
// Implementation to format data for HTTP communication.
|
|
30
48
|
return null;
|
|
31
49
|
}
|
|
32
|
-
|
|
33
50
|
}
|
|
34
|
-
|
|
35
51
|
}
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
namespace XmobiTea.GN.Entity
|
|
2
2
|
{
|
|
3
3
|
using System.Text;
|
|
4
|
-
|
|
5
4
|
using XmobiTea.GN.Common;
|
|
6
5
|
using XmobiTea.GN.Helper;
|
|
7
6
|
|
|
7
|
+
/// <summary>
|
|
8
|
+
/// Represents an operation request, encapsulating details such as operation code, parameters, encryption, and timeout.
|
|
9
|
+
/// </summary>
|
|
8
10
|
public class OperationRequest
|
|
9
11
|
{
|
|
12
|
+
/// <summary>
|
|
13
|
+
/// Default timeout for operation requests in seconds.
|
|
14
|
+
/// </summary>
|
|
10
15
|
public const int defaultTimeOut = 15;
|
|
11
16
|
|
|
12
17
|
private int operationCode;
|
|
@@ -15,6 +20,12 @@
|
|
|
15
20
|
private bool encrypted;
|
|
16
21
|
private int timeout;
|
|
17
22
|
|
|
23
|
+
/// <summary>
|
|
24
|
+
/// Initializes a new instance of the <see cref="OperationRequest"/> class.
|
|
25
|
+
/// </summary>
|
|
26
|
+
/// <param name="operationCode">The code representing the operation.</param>
|
|
27
|
+
/// <param name="encrypted">Indicates whether the request is encrypted.</param>
|
|
28
|
+
/// <param name="timeout">Timeout duration for the request.</param>
|
|
18
29
|
public OperationRequest(int operationCode, bool encrypted = true, int timeout = defaultTimeOut)
|
|
19
30
|
{
|
|
20
31
|
this.operationCode = operationCode;
|
|
@@ -22,78 +33,110 @@
|
|
|
22
33
|
this.timeout = timeout;
|
|
23
34
|
}
|
|
24
35
|
|
|
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
|
-
|
|
36
|
+
/// <summary>
|
|
37
|
+
/// Gets the operation code of the request.
|
|
38
|
+
/// </summary>
|
|
39
|
+
public int getOperationCode() => this.operationCode;
|
|
40
|
+
|
|
41
|
+
/// <summary>
|
|
42
|
+
/// Gets the request ID of the operation.
|
|
43
|
+
/// </summary>
|
|
44
|
+
public int getRequestId() => this.requestId;
|
|
45
|
+
|
|
46
|
+
/// <summary>
|
|
47
|
+
/// Gets the parameters associated with the operation.
|
|
48
|
+
/// </summary>
|
|
49
|
+
public GNHashtable getParameters() => this.parameters;
|
|
50
|
+
|
|
51
|
+
/// <summary>
|
|
52
|
+
/// Determines whether the request is encrypted.
|
|
53
|
+
/// </summary>
|
|
54
|
+
public bool isEncrypted() => this.encrypted;
|
|
55
|
+
|
|
56
|
+
/// <summary>
|
|
57
|
+
/// Gets the timeout duration for the request.
|
|
58
|
+
/// </summary>
|
|
59
|
+
public int getTimeout() => this.timeout;
|
|
60
|
+
|
|
61
|
+
/// <summary>
|
|
62
|
+
/// Sets the request ID for the operation.
|
|
63
|
+
/// </summary>
|
|
64
|
+
/// <param name="requestId">The request ID to set.</param>
|
|
65
|
+
/// <returns>The updated <see cref="OperationRequest"/> instance.</returns>
|
|
50
66
|
public OperationRequest setRequestId(int requestId)
|
|
51
67
|
{
|
|
52
68
|
this.requestId = requestId;
|
|
53
69
|
return this;
|
|
54
70
|
}
|
|
55
71
|
|
|
72
|
+
/// <summary>
|
|
73
|
+
/// Adds or updates a parameter for the operation.
|
|
74
|
+
/// </summary>
|
|
75
|
+
/// <param name="key">The parameter key.</param>
|
|
76
|
+
/// <param name="value">The parameter value.</param>
|
|
77
|
+
/// <returns>The updated <see cref="OperationRequest"/> instance.</returns>
|
|
56
78
|
public OperationRequest setParameter(string key, object value)
|
|
57
79
|
{
|
|
58
80
|
if (this.parameters == null) this.parameters = new GNHashtable();
|
|
59
|
-
|
|
60
81
|
this.parameters.add(key, value);
|
|
61
|
-
|
|
62
82
|
return this;
|
|
63
83
|
}
|
|
64
84
|
|
|
85
|
+
/// <summary>
|
|
86
|
+
/// Sets the parameters for the operation.
|
|
87
|
+
/// </summary>
|
|
88
|
+
/// <param name="parameters">The parameters to set.</param>
|
|
89
|
+
/// <returns>The updated <see cref="OperationRequest"/> instance.</returns>
|
|
65
90
|
public OperationRequest setParameters(GNHashtable parameters)
|
|
66
91
|
{
|
|
67
92
|
this.parameters = parameters;
|
|
68
93
|
return this;
|
|
69
94
|
}
|
|
70
95
|
|
|
96
|
+
/// <summary>
|
|
97
|
+
/// Sets whether the request is encrypted.
|
|
98
|
+
/// </summary>
|
|
99
|
+
/// <param name="encrypted">True if the request should be encrypted; otherwise false.</param>
|
|
100
|
+
/// <returns>The updated <see cref="OperationRequest"/> instance.</returns>
|
|
71
101
|
public OperationRequest setEncrypted(bool encrypted)
|
|
72
102
|
{
|
|
73
103
|
this.encrypted = encrypted;
|
|
74
104
|
return this;
|
|
75
105
|
}
|
|
76
106
|
|
|
107
|
+
/// <summary>
|
|
108
|
+
/// Sets the timeout duration for the request.
|
|
109
|
+
/// </summary>
|
|
110
|
+
/// <param name="timeout">Timeout duration in seconds.</param>
|
|
111
|
+
/// <returns>The updated <see cref="OperationRequest"/> instance.</returns>
|
|
77
112
|
public OperationRequest setTimeout(int timeout)
|
|
78
113
|
{
|
|
79
114
|
this.timeout = timeout;
|
|
80
115
|
return this;
|
|
81
116
|
}
|
|
82
117
|
|
|
118
|
+
/// <summary>
|
|
119
|
+
/// Converts the operation request to a string representation.
|
|
120
|
+
/// </summary>
|
|
121
|
+
/// <returns>A string representation of the operation request.</returns>
|
|
83
122
|
public string toString()
|
|
84
123
|
{
|
|
85
124
|
var stringBuilder = new StringBuilder();
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
125
|
+
stringBuilder.Append("Code: ")
|
|
126
|
+
.Append(CodeHelper.getOperationCodeName(this.operationCode))
|
|
127
|
+
.Append(", requestId: ")
|
|
128
|
+
.Append(this.requestId)
|
|
129
|
+
.Append(", parameters: ")
|
|
130
|
+
.Append(this.parameters)
|
|
131
|
+
.Append(", encrypted: ")
|
|
132
|
+
.Append(this.encrypted);
|
|
89
133
|
return stringBuilder.ToString();
|
|
90
134
|
}
|
|
91
135
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
136
|
+
/// <summary>
|
|
137
|
+
/// Returns a string that represents the current operation request.
|
|
138
|
+
/// </summary>
|
|
139
|
+
/// <returns>A string representation of the operation request.</returns>
|
|
140
|
+
public override string ToString() => this.toString();
|
|
97
141
|
}
|
|
98
|
-
|
|
99
142
|
}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
namespace XmobiTea.GN.Entity
|
|
2
2
|
{
|
|
3
3
|
using System.Text;
|
|
4
|
-
|
|
5
|
-
using XmobiTea.GN.Constant;
|
|
6
4
|
using XmobiTea.GN.Common;
|
|
5
|
+
using XmobiTea.GN.Constant;
|
|
7
6
|
using XmobiTea.GN.Helper;
|
|
8
7
|
|
|
8
|
+
/// <summary>
|
|
9
|
+
/// Represents an operation response, encapsulating details such as operation code, return code, debug messages, and parameters.
|
|
10
|
+
/// </summary>
|
|
9
11
|
public class OperationResponse
|
|
10
12
|
{
|
|
11
13
|
private int operationCode;
|
|
@@ -17,6 +19,12 @@
|
|
|
17
19
|
|
|
18
20
|
private InvalidMember[] invalidMembers;
|
|
19
21
|
|
|
22
|
+
/// <summary>
|
|
23
|
+
/// Initializes a new instance of the <see cref="OperationResponse"/> class.
|
|
24
|
+
/// </summary>
|
|
25
|
+
/// <param name="operationCode">The operation code associated with the response.</param>
|
|
26
|
+
/// <param name="responseId">The response ID.</param>
|
|
27
|
+
/// <param name="encrypted">Indicates whether the response is encrypted.</param>
|
|
20
28
|
public OperationResponse(int operationCode, int responseId, bool encrypted = true)
|
|
21
29
|
{
|
|
22
30
|
this.operationCode = operationCode;
|
|
@@ -26,119 +34,159 @@
|
|
|
26
34
|
this.debugMessage = null;
|
|
27
35
|
}
|
|
28
36
|
|
|
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
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
37
|
+
/// <summary>
|
|
38
|
+
/// Gets the operation code of the response.
|
|
39
|
+
/// </summary>
|
|
40
|
+
public int getOperationCode() => this.operationCode;
|
|
41
|
+
|
|
42
|
+
/// <summary>
|
|
43
|
+
/// Gets the return code of the response.
|
|
44
|
+
/// </summary>
|
|
45
|
+
public int getReturnCode() => this.returnCode;
|
|
46
|
+
|
|
47
|
+
/// <summary>
|
|
48
|
+
/// Gets the parameters associated with the response.
|
|
49
|
+
/// </summary>
|
|
50
|
+
public GNHashtable getParameters() => this.parameters;
|
|
51
|
+
|
|
52
|
+
/// <summary>
|
|
53
|
+
/// Determines whether the response is encrypted.
|
|
54
|
+
/// </summary>
|
|
55
|
+
public bool isEncrypted() => this.encrypted;
|
|
56
|
+
|
|
57
|
+
/// <summary>
|
|
58
|
+
/// Gets the response ID of the operation.
|
|
59
|
+
/// </summary>
|
|
60
|
+
public int getResponseId() => this.responseId;
|
|
61
|
+
|
|
62
|
+
/// <summary>
|
|
63
|
+
/// Gets the debug message, if any.
|
|
64
|
+
/// </summary>
|
|
65
|
+
public string getDebugMessage() => this.debugMessage;
|
|
66
|
+
|
|
67
|
+
/// <summary>
|
|
68
|
+
/// Gets the invalid members, if any, associated with the response.
|
|
69
|
+
/// </summary>
|
|
70
|
+
public InvalidMember[] getInvalidMembers() => this.invalidMembers;
|
|
71
|
+
|
|
72
|
+
/// <summary>
|
|
73
|
+
/// Determines whether the response has an error based on the return code.
|
|
74
|
+
/// </summary>
|
|
75
|
+
public bool hasError() => this.getReturnCode() != ReturnCode.Ok;
|
|
76
|
+
|
|
77
|
+
/// <summary>
|
|
78
|
+
/// Sets the return code for the response.
|
|
79
|
+
/// </summary>
|
|
80
|
+
/// <param name="returnCode">The return code to set.</param>
|
|
81
|
+
/// <returns>The updated <see cref="OperationResponse"/> instance.</returns>
|
|
69
82
|
public OperationResponse setReturnCode(int returnCode)
|
|
70
83
|
{
|
|
71
84
|
this.returnCode = returnCode;
|
|
72
85
|
return this;
|
|
73
86
|
}
|
|
74
87
|
|
|
88
|
+
/// <summary>
|
|
89
|
+
/// Sets the debug message for the response.
|
|
90
|
+
/// </summary>
|
|
91
|
+
/// <param name="debugMessage">The debug message to set.</param>
|
|
92
|
+
/// <returns>The updated <see cref="OperationResponse"/> instance.</returns>
|
|
75
93
|
public OperationResponse setDebugMessage(string debugMessage)
|
|
76
94
|
{
|
|
77
95
|
this.debugMessage = debugMessage;
|
|
78
96
|
return this;
|
|
79
97
|
}
|
|
80
98
|
|
|
99
|
+
/// <summary>
|
|
100
|
+
/// Adds or updates a parameter for the response.
|
|
101
|
+
/// </summary>
|
|
102
|
+
/// <param name="key">The parameter key.</param>
|
|
103
|
+
/// <param name="value">The parameter value.</param>
|
|
104
|
+
/// <returns>The updated <see cref="OperationResponse"/> instance.</returns>
|
|
81
105
|
public OperationResponse setParameter(string key, object value)
|
|
82
106
|
{
|
|
83
107
|
if (this.parameters == null) this.parameters = new GNHashtable();
|
|
84
|
-
|
|
85
108
|
this.parameters.add(key, value);
|
|
86
|
-
|
|
87
109
|
return this;
|
|
88
110
|
}
|
|
89
111
|
|
|
112
|
+
/// <summary>
|
|
113
|
+
/// Sets the parameters for the response.
|
|
114
|
+
/// </summary>
|
|
115
|
+
/// <param name="parameters">The parameters to set.</param>
|
|
116
|
+
/// <returns>The updated <see cref="OperationResponse"/> instance.</returns>
|
|
90
117
|
public OperationResponse setParameters(GNHashtable parameters)
|
|
91
118
|
{
|
|
92
119
|
this.parameters = parameters;
|
|
93
120
|
return this;
|
|
94
121
|
}
|
|
95
122
|
|
|
123
|
+
/// <summary>
|
|
124
|
+
/// Sets whether the response is encrypted.
|
|
125
|
+
/// </summary>
|
|
126
|
+
/// <param name="encrypted">True if the response should be encrypted; otherwise false.</param>
|
|
127
|
+
/// <returns>The updated <see cref="OperationResponse"/> instance.</returns>
|
|
96
128
|
public OperationResponse setEncrypted(bool encrypted)
|
|
97
129
|
{
|
|
98
130
|
this.encrypted = encrypted;
|
|
99
131
|
return this;
|
|
100
132
|
}
|
|
101
133
|
|
|
134
|
+
/// <summary>
|
|
135
|
+
/// Sets the invalid members for the response.
|
|
136
|
+
/// </summary>
|
|
137
|
+
/// <param name="invalidMembers">The invalid members to set.</param>
|
|
138
|
+
/// <returns>The updated <see cref="OperationResponse"/> instance.</returns>
|
|
102
139
|
public OperationResponse setInvalidMembers(InvalidMember[] invalidMembers)
|
|
103
140
|
{
|
|
104
141
|
this.invalidMembers = invalidMembers;
|
|
105
142
|
return this;
|
|
106
143
|
}
|
|
107
144
|
|
|
145
|
+
/// <summary>
|
|
146
|
+
/// Converts the operation response to a string representation.
|
|
147
|
+
/// </summary>
|
|
148
|
+
/// <returns>A string representation of the operation response.</returns>
|
|
108
149
|
public string toString()
|
|
109
150
|
{
|
|
110
151
|
var stringBuilder = new StringBuilder();
|
|
111
152
|
|
|
112
|
-
stringBuilder.Append("Code: "
|
|
153
|
+
stringBuilder.Append("Code: ")
|
|
154
|
+
.Append(CodeHelper.getOperationCodeName(this.operationCode))
|
|
155
|
+
.Append(", responseId: ")
|
|
156
|
+
.Append(this.responseId)
|
|
157
|
+
.Append(", returnCode: ")
|
|
158
|
+
.Append(CodeHelper.getReturnCodeName(this.returnCode));
|
|
113
159
|
|
|
114
|
-
if (this.returnCode == ReturnCode.Ok)
|
|
160
|
+
if (this.returnCode == ReturnCode.Ok)
|
|
161
|
+
{
|
|
162
|
+
stringBuilder.Append(", parameters: ").Append(this.parameters);
|
|
163
|
+
}
|
|
115
164
|
else if (this.returnCode == ReturnCode.InvalidRequestParameters)
|
|
116
165
|
{
|
|
117
166
|
if (this.invalidMembers != null)
|
|
118
167
|
{
|
|
119
|
-
var invalidStr = string.
|
|
120
|
-
|
|
121
|
-
foreach (var invalidMember in this.invalidMembers)
|
|
122
|
-
{
|
|
123
|
-
invalidStr += invalidMember;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
stringBuilder.Append(", invalidMembers " + invalidStr);
|
|
168
|
+
var invalidStr = string.Join(", ", this.invalidMembers);
|
|
169
|
+
stringBuilder.Append(", invalidMembers: ").Append(invalidStr);
|
|
127
170
|
}
|
|
128
|
-
else
|
|
171
|
+
else
|
|
172
|
+
{
|
|
173
|
+
stringBuilder.Append(", invalidMembers: null");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
else
|
|
177
|
+
{
|
|
178
|
+
stringBuilder.Append(", debugMessage: ").Append(this.debugMessage);
|
|
129
179
|
}
|
|
130
|
-
else stringBuilder.Append(", debugMessage " + this.debugMessage);
|
|
131
180
|
|
|
132
|
-
stringBuilder.Append(", encrypted "
|
|
181
|
+
stringBuilder.Append(", encrypted: ").Append(this.encrypted);
|
|
133
182
|
|
|
134
183
|
return stringBuilder.ToString();
|
|
135
184
|
}
|
|
136
185
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
186
|
+
/// <summary>
|
|
187
|
+
/// Returns a string that represents the current operation response.
|
|
188
|
+
/// </summary>
|
|
189
|
+
/// <returns>A string representation of the operation response.</returns>
|
|
190
|
+
public override string ToString() => this.toString();
|
|
142
191
|
}
|
|
143
|
-
|
|
144
192
|
}
|