Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
SCR_BackendCallback.c
Go to the documentation of this file.
1 
10 //------------------------------------------------------------------------------------------------
13 {
17 };
18 
19 //------------------------------------------------------------------------------------------------
22 {
23  // Cache
24  protected int m_iCode = -1;
25  protected int m_iRestCode = -1;
26  protected int m_iApiCode = -1;
27  protected EBackendCallbackResponse m_Result = -1;
28 
29  // Invokers
30  protected ref ScriptInvoker<SCR_BackendCallback> Event_OnSuccess;
31  protected ref ScriptInvoker<SCR_BackendCallback, int, int, int> Event_OnFail;
32  protected ref ScriptInvoker<SCR_BackendCallback> Event_OnTimeOut;
33 
34  protected ref ScriptInvoker<SCR_BackendCallback> Event_OnResponse;
35 
36  //------------------------------------------------------------------------------------------------
37  // Invokers api
38  //------------------------------------------------------------------------------------------------
39 
40  //------------------------------------------------------------------------------------------------
41  protected void InvokeEventOnSuccess()
42  {
43  if (Event_OnSuccess)
44  Event_OnSuccess.Invoke(this);
45  }
46 
47  //------------------------------------------------------------------------------------------------
48  ScriptInvoker GetEventOnSuccess()
49  {
50  if (!Event_OnSuccess)
51  Event_OnSuccess = new ScriptInvoker();
52 
53  return Event_OnSuccess;
54  }
55 
56  //------------------------------------------------------------------------------------------------
57  protected void InvokeEventOnFail(SCR_BackendCallback callback, int code, int restCode, int apiCode)
58  {
59  if (Event_OnFail)
60  Event_OnFail.Invoke(callback, code, restCode, apiCode);
61  }
62 
63  //------------------------------------------------------------------------------------------------
64  ScriptInvoker GetEventOnFail()
65  {
66  if (!Event_OnFail)
67  Event_OnFail = new ScriptInvoker();
68 
69  return Event_OnFail;
70  }
71 
72  //------------------------------------------------------------------------------------------------
73  protected void InvokeEventOnTimeOut()
74  {
75  if (Event_OnTimeOut)
76  Event_OnTimeOut.Invoke(this);
77  }
78 
79  //------------------------------------------------------------------------------------------------
80  ScriptInvoker GetEventOnTimeOut()
81  {
82  if (!Event_OnTimeOut)
83  Event_OnTimeOut = new ScriptInvoker();
84 
85  return Event_OnTimeOut;
86  }
87 
88  //------------------------------------------------------------------------------------------------
89  protected void InvokeEventOnResponse()
90  {
91  if (Event_OnResponse)
92  Event_OnResponse.Invoke(this);
93  }
94 
95  //------------------------------------------------------------------------------------------------
96  ScriptInvoker GetEventOnResponse()
97  {
98  if (!Event_OnResponse)
99  Event_OnResponse = new ScriptInvoker();
100 
101  return Event_OnResponse;
102  }
103 
104  //------------------------------------------------------------------------------------------------
105  // Override API
106  //------------------------------------------------------------------------------------------------
107 
108  //------------------------------------------------------------------------------------------------
109  override void OnSuccess(int code)
110  {
111  CacheLastResponse(EBackendCallbackResponse.SUCCESS, code);
112 
113  InvokeEventOnSuccess();
114 
115  InvokeEventOnResponse();
116  }
117 
118  //------------------------------------------------------------------------------------------------
119  override void OnError(int code, int restCode, int apiCode)
120  {
121  CacheLastResponse(EBackendCallbackResponse.ERROR, code, restCode, apiCode);
122  InvokeEventOnFail(this, code, restCode, apiCode);
123 
124  InvokeEventOnResponse();
125  }
126 
127  //------------------------------------------------------------------------------------------------
128  override void OnTimeout()
129  {
130  CacheLastResponse(EBackendCallbackResponse.TIMEOUT);
131  InvokeEventOnTimeOut();
132 
133  InvokeEventOnResponse();
134  }
135 
136 
137 
138  //------------------------------------------------------------------------------------------------
139  // Protected API
140  //------------------------------------------------------------------------------------------------
141 
142  //------------------------------------------------------------------------------------------------
144  protected void CacheLastResponse(EBackendCallbackResponse result, int code = -1, int restCode = -1, int apiCode = -1)
145  {
146  m_Result = result;
147  m_iCode = code;
148  m_iRestCode = restCode;
149  m_iApiCode = apiCode;
150  }
151 
152 
153 
154  //------------------------------------------------------------------------------------------------
155  // Getter API
156  //------------------------------------------------------------------------------------------------
157 
158  //------------------------------------------------------------------------------------------------
159  int GetCode()
160  {
161  return m_iCode;
162  }
163 
164  //------------------------------------------------------------------------------------------------
165  int GetRestCode()
166  {
167  return m_iRestCode;
168  }
169 
170  //------------------------------------------------------------------------------------------------
171  int GetApiCode()
172  {
173  return m_iApiCode;
174  }
175 
176  //------------------------------------------------------------------------------------------------
177  EBackendCallbackResponse GetResponseType()
178  {
179  return m_Result;
180  }
181 };
ERROR
@ ERROR
Definition: SCR_BackendCallback.c:15
SCR_BackendCallback
Scripted backend callback class unifying backend response.
Definition: SCR_BackendCallback.c:21
BackendCallback
Base server browser callback.
Definition: SCR_ServerListComponent.c:4
TIMEOUT
@ TIMEOUT
Definition: SCR_BackendCallback.c:16
EBackendCallbackResponse
EBackendCallbackResponse
Basic callback responses.
Definition: SCR_BackendCallback.c:12
callback
DownloadConfigCallback callback
SUCCESS
@ SUCCESS
Definition: SCR_BackendCallback.c:14