Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
restapi.c
Go to the documentation of this file.
1
5// -------------------------------------------------------------------------
6// states, (result + error) codes
7// defined in C++
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)
23};
24
25// -------------------------------------------------------------------------
26// options
27// defined in C++
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//
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
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
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
181proto native RestApi CreateRestApi();
182proto native void DestroyRestApi();
183proto native RestApi GetRestApi();
184
TODO doc.
Definition enscript.c:118
proto void Print(void var)
Prints content of variable to console/log.
enum ParticleAutoDestroyFlags FILE
Filename only ("smoking_barrel_small")
proto native RestApi GetRestApi()
proto native void DestroyRestApi()
ERestResultState
Definition restapi.c:9
@ EREST_FEEDING
Definition restapi.c:12
@ EREST_ERROR_CLIENTERROR
Definition restapi.c:17
@ EREST_PROCESSED
Definition restapi.c:14
@ EREST_ERROR_APPERROR
Definition restapi.c:19
@ EREST_PENDING
Definition restapi.c:11
@ EREST_ERROR_SERVERERROR
Definition restapi.c:18
@ EREST_ERROR_UNKNOWN
Definition restapi.c:22
@ EREST_ERROR_TIMEOUT
Definition restapi.c:20
@ EREST_ERROR
Definition restapi.c:16
@ EREST_EMPTY
Definition restapi.c:10
@ EREST_SUCCESS
Definition restapi.c:13
@ EREST_ERROR_NOTIMPLEMENTED
Definition restapi.c:21
ERestOption
Definition restapi.c:29
@ ERESTOPTION_READOPERATION
Definition restapi.c:32
@ ERESTOPTION_UNKNOWN
Definition restapi.c:30
@ ERESTOPTION_CONNECTION
Definition restapi.c:33
proto native RestApi CreateRestApi()