7
7
extends RefCounted
8
8
9
9
enum UroUserContentType { UNKNOWN , AVATAR , MAP , PROP }
10
+ enum RequesterCode {
11
+ OK = 0 ,
12
+ CANCELLED ,
13
+ TERMINATED ,
14
+ CANT_CONNECT ,
15
+ CANT_RESOLVE ,
16
+ SSL_HANDSHAKE_ERROR ,
17
+ DISCONNECTED ,
18
+ CONNECTION_ERROR ,
19
+ UNKNOWN_STATUS_ERROR ,
20
+ FILE_ERROR ,
21
+ HTTP_RESPONSE_NOT_OK ,
22
+ NO_TOKEN ,
23
+ MALFORMED_RESPONSE_DATA ,
24
+ JSON_PARSE_ERROR ,
25
+ JSON_VALIDATE_ERROR ,
26
+ NO_RESPONSE_BODY ,
27
+ FAILED_TO_CONNECT ,
28
+ POLL_ERROR ,
29
+ }
10
30
11
31
const LOCALHOST_HOST = "127.0.0.1"
12
32
const LOCALHOST_PORT = 4000
13
-
14
33
const DEFAULT_URO_HOST = LOCALHOST_HOST
15
34
const DEFAULT_URO_PORT = LOCALHOST_PORT
16
-
17
35
const API_PATH = "/api"
18
36
const API_VERSION = "/v1"
19
-
20
37
const SHOW_PATH = "/show"
21
38
const NEW_PATH = "/new"
22
39
const RENEW_PATH = "/renew"
23
-
24
40
const PROFILE_PATH = "/profile"
25
41
const SESSION_PATH = "/session"
26
42
const REGISTRATION_PATH = "/registration"
@@ -29,35 +45,12 @@ const AVATARS_PATH = "/avatars"
29
45
const MAPS_PATH = "/maps"
30
46
const SHARDS_PATH = "/shards"
31
47
const DASHBOARD_PATH = "/dashboard"
32
-
33
48
const DEFAULT_ACCOUNT_ID = "UNKNOWN_ID"
34
49
const DEFAULT_ACCOUNT_USERNAME = "UNKNOWN_USERNAME"
35
50
const DEFAULT_ACCOUNT_DISPLAY_NAME = "UNKNOWN_DISPLAY_NAME"
36
-
37
51
const UNTITLED_SHARD = "UNTITLED_SHARD"
38
52
const UNKNOWN_MAP = "UNKNOWN_MAP"
39
53
40
- enum RequesterCode {
41
- OK = 0 ,
42
- CANCELLED ,
43
- TERMINATED ,
44
- CANT_CONNECT ,
45
- CANT_RESOLVE ,
46
- SSL_HANDSHAKE_ERROR ,
47
- DISCONNECTED ,
48
- CONNECTION_ERROR ,
49
- UNKNOWN_STATUS_ERROR ,
50
- FILE_ERROR ,
51
- HTTP_RESPONSE_NOT_OK ,
52
- NO_TOKEN ,
53
- MALFORMED_RESPONSE_DATA ,
54
- JSON_PARSE_ERROR ,
55
- JSON_VALIDATE_ERROR ,
56
- NO_RESPONSE_BODY ,
57
- FAILED_TO_CONNECT ,
58
- POLL_ERROR ,
59
- }
60
-
61
54
62
55
static func get_string_for_requester_code (p_requester_code : int ) -> String :
63
56
match p_requester_code :
@@ -108,41 +101,37 @@ static func get_full_requester_error_string(p_requester: Dictionary) -> String:
108
101
p_requester ["generic_code" ]
109
102
]
110
103
)
111
- elif p_requester ["requester_code" ] == RequesterCode .HTTP_RESPONSE_NOT_OK :
104
+
105
+ if p_requester ["requester_code" ] == RequesterCode .HTTP_RESPONSE_NOT_OK :
112
106
return (
113
107
"%s (error code: %s )"
114
108
% [
115
109
get_string_for_requester_code (p_requester ["requester_code" ]),
116
110
p_requester ["response_code" ]
117
111
]
118
112
)
119
- elif p_requester ["requester_code" ] == RequesterCode .POLL_ERROR :
113
+
114
+ if p_requester ["requester_code" ] == RequesterCode .POLL_ERROR :
120
115
return (
121
116
"%s (error code: %s )"
122
117
% [
123
118
get_string_for_requester_code (p_requester ["requester_code" ]),
124
119
p_requester ["generic_code" ]
125
120
]
126
121
)
127
- else :
128
- return get_string_for_requester_code (p_requester ["requester_code" ])
122
+
123
+ return get_string_for_requester_code (p_requester ["requester_code" ])
129
124
130
125
131
126
static func requester_result_is_ok (p_result ) -> bool :
132
- if p_result ["requester_code" ] == RequesterCode .OK :
133
- return true
134
- else :
135
- return false
127
+ return p_result ["requester_code" ] == RequesterCode .OK
136
128
137
129
138
130
static func requester_result_has_response (p_result ) -> bool :
139
- if (
131
+ return (
140
132
p_result ["requester_code" ] == RequesterCode .OK
141
133
or p_result ["requester_code" ] == RequesterCode .HTTP_RESPONSE_NOT_OK
142
- ):
143
- return true
144
- else :
145
- return false
134
+ )
146
135
147
136
148
137
static func populate_query (p_query_name : String , p_query_dictionary : Dictionary ) -> Dictionary :
@@ -162,8 +151,7 @@ static func get_value_of_type(p_data: Dictionary, p_key: String, p_type: int, p_
162
151
var value = p_data .get (p_key , p_default_value )
163
152
if typeof (value ) == p_type :
164
153
return value
165
- else :
166
- return p_default_value
154
+ return p_default_value
167
155
168
156
169
157
static func process_user_privilege_ruleset (p_data ) -> Dictionary :
@@ -236,34 +224,33 @@ static func process_session_json(p_input: Dictionary) -> Dictionary:
236
224
"message" : "Malformed response data!" ,
237
225
}
238
226
239
- else :
240
- var output = p_input .get ("output" )
241
- if output is Dictionary :
242
- var error = output .get ("error" )
243
- if error is Dictionary :
244
- var message = error .get ("message" )
245
- if message is String :
246
- return {
247
- "requester_code" : p_input ["requester_code" ],
248
- "generic_code" : p_input ["generic_code" ],
249
- "response_code" : p_input ["response_code" ],
250
- "message" : message
251
- }
227
+ var output = p_input .get ("output" )
228
+ if output is Dictionary :
229
+ var error = output .get ("error" )
230
+ if error is Dictionary :
231
+ var message = error .get ("message" )
232
+ if message is String :
233
+ return {
234
+ "requester_code" : p_input ["requester_code" ],
235
+ "generic_code" : p_input ["generic_code" ],
236
+ "response_code" : p_input ["response_code" ],
237
+ "message" : message
238
+ }
252
239
253
- return {
254
- "requester_code" : RequesterCode .MALFORMED_RESPONSE_DATA ,
255
- "generic_code" : p_input ["generic_code" ],
256
- "response_code" : p_input ["response_code" ],
257
- "message" : get_full_requester_error_string (p_input )
258
- }
259
- else :
260
240
return {
261
- "requester_code" : p_input [ "requester_code" ] ,
241
+ "requester_code" : RequesterCode . MALFORMED_RESPONSE_DATA ,
262
242
"generic_code" : p_input ["generic_code" ],
263
243
"response_code" : p_input ["response_code" ],
264
244
"message" : get_full_requester_error_string (p_input )
265
245
}
266
246
247
+ return {
248
+ "requester_code" : p_input ["requester_code" ],
249
+ "generic_code" : p_input ["generic_code" ],
250
+ "response_code" : p_input ["response_code" ],
251
+ "message" : get_full_requester_error_string (p_input )
252
+ }
253
+
267
254
268
255
static func process_shards_json (p_input : Dictionary ) -> Dictionary :
269
256
var result_dict : Dictionary = {}
0 commit comments