Dayz Explorer
1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
restapi.c
Go to the documentation of this file.
1
5
// -------------------------------------------------------------------------
6
// states, (result + error) codes
7
// defined in C++
8
enum
ERestResultState
9
{
10
EREST_EMPTY
,
// not initialized
11
EREST_PENDING
,
// awaiting processing
12
EREST_FEEDING
,
// awaiting incoming data
13
EREST_SUCCESS
,
// result and/ or data are ready (success), awaiting data processing to be finished (no longer blocking queue processing)
14
EREST_PROCESSED
,
// finished (either successfully or with failure) and eill be removed ASAP
15
16
EREST_ERROR
,
// (state >= EREST_ERROR) == error happened
17
EREST_ERROR_CLIENTERROR
,
// (EREST_ERROR == EREST_ERROR_CLIENTERROR)
18
EREST_ERROR_SERVERERROR
,
19
EREST_ERROR_APPERROR
,
20
EREST_ERROR_TIMEOUT
,
21
EREST_ERROR_NOTIMPLEMENTED
,
22
EREST_ERROR_UNKNOWN
,
23
};
24
25
// -------------------------------------------------------------------------
26
// options
27
// defined in C++
28
enum
ERestOption
29
{
30
ERESTOPTION_UNKNOWN
,
// invalid option
31
32
ERESTOPTION_READOPERATION
,
// read operation timeout (default 10sec)
33
ERESTOPTION_CONNECTION
,
// connection timeout (default 10sec)
34
// note: limit for timeout is between <3 .. 120> seconds, you cannot exceed this value
35
};
36
37
38
39
// -------------------------------------------------------------------------
40
// object to be used from script for result binding
41
//
42
// [Example:]
43
//
44
// RestCallback cbx1 = new RestCallback;
45
// RestContext ctx = GetRestApi().GetRestContext("http://somethingsomewhere.com/path/");
46
// ctx.GET(cbx1,"RequestPath?Argument=Something");
47
//
48
// Event are then called upon RestCallback()
49
//
50
class
RestCallback
:
Managed
51
{
55
void
OnError(
int
errorCode )
56
{
57
// override this with your implementation
58
Print
(
" !!! OnError() "
);
59
};
60
64
void
OnTimeout()
65
{
66
// override this with your implementation
67
Print
(
" !!! OnTimeout() "
);
68
};
69
73
void
OnSuccess(
string
data,
int
dataSize )
74
{
75
// override this with your implementation
76
Print
(
" !!! OnSuccess() size="
+ dataSize );
77
if
( dataSize > 0 )
78
Print
(data);
// !!! NOTE: Print() will not output string longer than 1024b, check your dataSize !!!
79
};
80
84
void
OnFileCreated(
string
fileName,
int
dataSize )
85
{
86
// override this with your implementation
87
Print
(
" !!! OnFileCreated() file="
+ fileName +
" size="
+ dataSize );
88
};
89
90
};
91
92
93
// -------------------------------------------------------------------------
94
// context API and request API
95
class
RestContext
96
{
97
private
void
RestContext
() {}
98
private
void
~
RestContext
() {}
99
103
proto native
int
GET(
RestCallback
cb,
string
request );
104
108
proto native
string
GET_now(
string
request );
109
113
proto native
int
FILE(
RestCallback
cb,
string
request,
string
filename );
114
118
proto native
int
FILE_now(
string
request,
string
filename );
119
123
proto native
int
POST(
RestCallback
cb,
string
request,
string
data );
124
128
proto native
string
POST_now(
string
request,
string
data );
129
133
proto native
void
reset();
134
141
proto native
void
SetHeader(
string
value );
142
};
143
144
145
// -------------------------------------------------------------------------
146
// RestApi core for context create/ access + debug features
147
class
RestApi
148
{
149
private
void
RestApi
() {}
150
private
void
~
RestApi
() {}
151
155
proto native
RestContext
GetRestContext(
string
serverURL );
156
160
proto native
int
GetContextCount();
161
165
proto native
void
EnableDebug(
bool
bEnable );
166
170
proto native
void
DebugList();
171
175
proto native
void
SetOption(
int
option,
int
value );
176
177
};
178
179
// -------------------------------------------------------------------------
180
// RestApi create/ access methods out of Hive initialization
181
proto native
RestApi
CreateRestApi
();
182
proto native
void
DestroyRestApi
();
183
proto native
RestApi
GetRestApi
();
184
EREST_ERROR_NOTIMPLEMENTED
@ EREST_ERROR_NOTIMPLEMENTED
Definition:
restapi.c:21
EREST_PROCESSED
@ EREST_PROCESSED
Definition:
restapi.c:14
ERestOption
ERestOption
Definition:
restapi.c:28
Managed
TODO doc.
Definition:
enscript.c:117
Print
proto void Print(void var)
Prints content of variable to console/log.
EREST_ERROR_UNKNOWN
@ EREST_ERROR_UNKNOWN
Definition:
restapi.c:22
ERESTOPTION_UNKNOWN
@ ERESTOPTION_UNKNOWN
Definition:
restapi.c:30
EREST_SUCCESS
@ EREST_SUCCESS
Definition:
restapi.c:13
RestCallback
Definition:
restapi.c:50
DestroyRestApi
proto native void DestroyRestApi()
EREST_ERROR
@ EREST_ERROR
Definition:
restapi.c:16
RestApi
Definition:
restapi.c:147
RestContext
Definition:
restapi.c:95
CreateRestApi
proto native RestApi CreateRestApi()
EREST_ERROR_TIMEOUT
@ EREST_ERROR_TIMEOUT
Definition:
restapi.c:20
EREST_ERROR_SERVERERROR
@ EREST_ERROR_SERVERERROR
Definition:
restapi.c:18
EREST_FEEDING
@ EREST_FEEDING
Definition:
restapi.c:12
ERESTOPTION_CONNECTION
@ ERESTOPTION_CONNECTION
Definition:
restapi.c:33
EREST_PENDING
@ EREST_PENDING
Definition:
restapi.c:11
EREST_EMPTY
@ EREST_EMPTY
Definition:
restapi.c:10
GetRestApi
proto native RestApi GetRestApi()
EREST_ERROR_APPERROR
@ EREST_ERROR_APPERROR
Definition:
restapi.c:19
ERestResultState
ERestResultState
Definition:
restapi.c:8
ERESTOPTION_READOPERATION
@ ERESTOPTION_READOPERATION
Definition:
restapi.c:32
EREST_ERROR_CLIENTERROR
@ EREST_ERROR_CLIENTERROR
Definition:
restapi.c:17
DAYZ
scripts_v1.24.157551
scripts
game
http
restapi.c
Generated by
1.8.17