Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
backendapi.c
Go to the documentation of this file.
1
7 {
8 EBERR_OK, // all OK
9 EBERR_UNKNOWN, // unknown error
10 EBERR_DISABLED, // backend is disabled
11 EBERR_INVALID_STATE, // called request from state where it is not possible (ie. reading data before logon and such)
12 EBERR_BUSY, // no request can be called - login/ auth in process
13 EBERR_ALREADY_OFFLINE, // state is already active
14 EBERR_ALREADY_ONLINE, // state is already active
15 EBERR_ALREADY_REQUESTED, // state already requested once!
16 EBERR_LOGIN_FAILED, // failed to logon
17 EBERR_AUTH_FAILED, // failed to authenticate
18 EBERR_LOGIN_SUCCESS, // logon successfull
19 EBERR_AUTH_SUCCESS, // authenticate successfull
20 EBERR_CONFIGURATION_GET, // configuration received
21 EBERR_CEPROFILE_GET, // CE profile configuration received
22 EBERR_CHARACTER_GET, // character data receieved
23 EBERR_CHARACTER_UPDATE, // character update done
24 };
25
28 {
29/* // game api
30 EBREQ_GAME_Test, // environment test - dummy data read
31 EBREQ_GAME_World, // static world configuration read
32 EBREQ_GAME_CEProfile,
33 EBREQ_GAME_CharacterGet, // character data read
34 EBREQ_GAME_CharacterUpdate, // character data update
35// #if BACKENDAPI_DEV_CHARACTER
36 EBREQ_GAME_DevCharacterGet, // dev character data read
37 EBREQ_GAME_DevCharacterUpdate, // dev character data update
38// #endif
39 EBREQ_GAME_Heartbeat,*/
40 // user api request <> response
43/* // lobby api request <> response
44 EBREQ_LOBBY_RoomsRegister,
45 EBREQ_LOBBY_RoomsJoin,
46 EBREQ_LOBBY_RoomsAcceptPlayer,
47 EBREQ_LOBBY_RoomsHeartBeat,
48 EBREQ_LOBBY_RoomsUpdate,
49 EBREQ_LOBBY_RoomsRemovePlayer,
50 EBREQ_LOBBY_RoomsSearch,
51 EBREQ_LOBBY_RoomsGetByIds,
52 EBREQ_LOBBY_RoomsGetByHostIds,
53 EBREQ_LOBBY_GetActiveScenarios,
54 // storage api request <> response
55 EBREQ_STORAGE_GetFileTempURL,
56 EBREQ_STORAGE_GetFileTempURLS2S,
57 EBREQ_STORAGE_GetFile,
58 EBREQ_STORAGE_DeleteFile,
59 EBREQ_STORAGE_GetFileS2S,
60 EBREQ_STORAGE_DeleteFileS2S,
61 EBREQ_STORAGE_PatchFileS2S,
62 EBREQ_STORAGE_Upload,
63 EBREQ_STORAGE_UploadS2S,
64 EBREQ_STORAGE_UploadZip,
65 EBREQ_STORAGE_UploadZipS2S,
66 EBREQ_STORAGE_Limits,
67 EBREQ_STORAGE_LimitsS2S,
68 // feedback request <> response
69// #if ONLINE_SLACKAPI
70 EBREQ_SLACKAPI_PostMessage,
71// #endif*/
72 };
73
81
82
83// -------------------------------------------------------------------------
84// Callback interface for backend - must exist for the duration of request!
86{
92 void OnDataReceive( string data, int size )
93 {
94 Print("[BackendCallback] Data received, size=" + size);
95 Print(data);
96 }
97
102 void OnError( int code )
103 {
104 Print("[BackendCallback] OnError: " + GetBackendApi().GetErrorCode(code));
105 }
106
111 void OnSuccess( int code )
112 {
113 Print("[BackendCallback] OnSuccess()");
114 }
115
119 void OnTimeout()
120 {
121 Print("[BackendCallback] OnTimeout");
122 }
123
124};
125
126
127// -------------------------------------------------------------------------
128// Backend API access
130{
131 private void BackendApi() {}
132 private void ~BackendApi() {}
133
137 proto native bool Initiate();
141 proto native bool Shutdown();
142
143
147 proto native bool IsDisconnected();
151 proto native bool IsRuntime();
155 proto native bool IsBusy();
156
157
159 string GetErrorCode( int code )
160 {
161 string result;
162
163 if ( code == EBackendError.EBERR_OK )
164 result = "OK";
165 else if ( code == EBackendError.EBERR_UNKNOWN )
166 result = "Offline";
167 else if ( code == EBackendError.EBERR_DISABLED )
168 result = "Communication Disabled";
169 else if ( code == EBackendError.EBERR_INVALID_STATE )
170 result = "Cannot be called from current state";
171 else if ( code == EBackendError.EBERR_BUSY )
172 result = "Busy processing requests";
173 else if ( code == EBackendError.EBERR_ALREADY_OFFLINE )
174 result = "Already disconnected";
175 else if ( code == EBackendError.EBERR_ALREADY_ONLINE )
176 result = "Already connected";
177 else if ( code == EBackendError.EBERR_LOGIN_FAILED )
178 result = "Failed to logon";
179 else if ( code == EBackendError.EBERR_AUTH_FAILED )
180 result = "Failed to Authenticate";
181 else
182 result = "*";
183
184 return result;
185 }
186
190 void OnCannotInitiate( int code )
191 {
192 Print("!!! [Backend] Cannot Initiate: "+ GetErrorCode(code));
193 }
194
198 void OnCannotShutdown( int code )
199 {
200 Print("!!! [Backend] Cannot Shutdown: "+ GetErrorCode(code));
201 }
202
206 void OnSuccess( string step )
207 {
208 Print( "[Backend] Successfully Solicited: " + step );
209 }
210
214 void OnFail( string step )
215 {
216 Print( "[Backend] Failed to Proceed: " + step );
217 }
218
225 proto native void Request( int request, BackendCallback cb, JsonApiStruct dataObject );
226
234 proto native void PlayerRequest( int request, BackendCallback cb, JsonApiStruct dataObject, int iPlayerId );
235
242 proto native void FeedbackMessage( BackendCallback cb, JsonApiStruct dataObject, string message );
243
249 proto native void SetCredentialsItem( EBackendCredentials item, string str );
250
255 proto native string GetCredentialsItem( EBackendCredentials item );
256
260 proto native void VerifyCredentials();
261
262};
263
264
266
267// -------------------------------------------------------------------------
EBackendRequest
Backend request.
Definition backendapi.c:28
@ EBREQ_USER_Login
Definition backendapi.c:41
@ EBREQ_USER_Auth
Definition backendapi.c:42
EBackendCredentials
Credential parameters.
Definition backendapi.c:76
@ EBCRED_PWD
Definition backendapi.c:78
@ EBCRED_NAME
Definition backendapi.c:77
@ EBCRED_BASEURI
Definition backendapi.c:79
EBackendError
Backend error.
Definition backendapi.c:7
@ EBERR_LOGIN_SUCCESS
Definition backendapi.c:18
@ EBERR_INVALID_STATE
Definition backendapi.c:11
@ EBERR_CHARACTER_UPDATE
Definition backendapi.c:23
@ EBERR_ALREADY_ONLINE
Definition backendapi.c:14
@ EBERR_DISABLED
Definition backendapi.c:10
@ EBERR_OK
Definition backendapi.c:8
@ EBERR_CHARACTER_GET
Definition backendapi.c:22
@ EBERR_AUTH_FAILED
Definition backendapi.c:17
@ EBERR_CEPROFILE_GET
Definition backendapi.c:21
@ EBERR_ALREADY_REQUESTED
Definition backendapi.c:15
@ EBERR_ALREADY_OFFLINE
Definition backendapi.c:13
@ EBERR_BUSY
Definition backendapi.c:12
@ EBERR_AUTH_SUCCESS
Definition backendapi.c:19
@ EBERR_UNKNOWN
Definition backendapi.c:9
@ EBERR_LOGIN_FAILED
Definition backendapi.c:16
@ EBERR_CONFIGURATION_GET
Definition backendapi.c:20
proto native BackendApi GetBackendApi()
TODO doc.
Definition enscript.c:118
proto void Print(void var)
Prints content of variable to console/log.