DayZ 1.24
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
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
142
143
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
191 {
192 Print("!!! [Backend] Cannot Initiate: " + GetErrorCode(code));
193 }
194
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
226
235
243
250
256
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()
proto native string GetCredentialsItem(EBackendCredentials item)
Get credentials value per item.
proto native void PlayerRequest(int request, BackendCallback cb, JsonApiStruct dataObject, int iPlayerId)
Ask player request with callback result from controller (Lobby)
void OnCannotInitiate(int code)
Called when initiate cannot be called.
Definition BackendApi.c:190
void ~BackendApi()
Definition BackendApi.c:132
void OnSuccess(string step)
Called when step was successfully proceeded.
Definition BackendApi.c:206
proto native void VerifyCredentials()
Invoke credentials update (authenticate with new name+password)
proto native bool IsDisconnected()
Backend offline - authentication may be initiated.
proto native bool Initiate()
Initiate backend - request processing.
proto native void Request(int request, BackendCallback cb, JsonApiStruct dataObject)
Ask specific request with callback result.
void OnCannotShutdown(int code)
Called when shutdown cannot be proceeded.
Definition BackendApi.c:198
proto native bool Shutdown()
Shutdown backend - request processing.
proto native void FeedbackMessage(BackendCallback cb, JsonApiStruct dataObject, string message)
Send feedback message and/ or script object with whatever data on it (additionally it is possible to ...
proto native bool IsBusy()
Backend is busy - authentication in process.
void OnFail(string step)
Called when step failed.
Definition BackendApi.c:214
proto native void SetCredentialsItem(EBackendCredentials item, string str)
Set credentials value per item.
void BackendApi()
Definition BackendApi.c:131
proto native bool IsRuntime()
Backend fully working and initialized.
string GetErrorCode(int code)
Error code to string.
Definition BackendApi.c:159
void OnTimeout()
Request not finished due to timeout.
Definition BackendApi.c:119
void OnDataReceive(string data, int size)
Called when data were recieved, you can ignore it when using callback to JsonStruct object with expan...
Definition BackendApi.c:92
void OnSuccess(int code)
Request finished with success result.
Definition BackendApi.c:111
void OnError(int code)
Request finished with error result.
Definition BackendApi.c:102
TODO doc.
Definition EnScript.c:118
proto void Print(void var)
Prints content of variable to console/log.