Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
UploadSaveCommand.c
Go to the documentation of this file.
2 {
7 }
8 
9 class StateBackendCallback : BackendCallback
10 {
12 
13  override void OnError( int code, int restCode, int apiCode )
14  {
15  m_eState = EBackendCallbackState.EBCS_ERROR;
16  }
17 
18  override void OnSuccess( int code )
19  {
20  m_eState = EBackendCallbackState.EBCS_SUCCESS;
21  }
22 
23  override void OnTimeout()
24  {
25  m_eState = EBackendCallbackState.EBCS_TIMEOUT;
26  }
27 }
28 
29 
31 {
32  protected ref StateBackendCallback m_callback;
33 
34  protected ref ScrServerCmdResult m_result = new ScrServerCmdResult(string.Empty, EServerCmdResultType.PENDING);
35 
36  override event string GetKeyword()
37  {
38  return "upload";
39  }
40 
41  override event protected ref ScrServerCmdResult OnChatClientExecution(array<string> argv, int playerId)
42  {
43  m_result.m_eResultType = EServerCmdResultType.OK;
44  m_result.m_sResponse = string.Empty;
45  return m_result;
46  }
47 
48  protected override ref ScrServerCmdResult OnChatServerExecution(array<string> argv, int playerId)
49  {
50  m_result.m_sResponse = string.Empty;
51 
52  if (argv.Count() < 2)
53  {
54  m_result.m_eResultType = EServerCmdResultType.PARAMETERS;
55  return m_result;
56  }
57 
58  m_callback = new StateBackendCallback;
59 
60 
61  //TODO pass the callback
62  GetGame().GetSaveManager().UploadToWorkshop(argv[1]);
63  return m_result;
64  }
65 
66  protected override ref ScrServerCmdResult OnUpdate()
67  {
68  switch(m_callback.m_eState)
69  {
70  case EBackendCallbackState.EBCS_SUCCESS: m_result.m_eResultType = EServerCmdResultType.OK; break;
71  case EBackendCallbackState.EBCS_PENDING: m_result.m_eResultType = EServerCmdResultType.PENDING; break;
72  case EBackendCallbackState.EBCS_TIMEOUT: m_result.m_eResultType = EServerCmdResultType.ERR; m_result.m_sResponse = "Timeout"; break;
73  default: m_result.m_eResultType = EServerCmdResultType.ERR; break;
74  }
75  return m_result;
76  }
77 
78  override event protected int RequiredChatPermission()
79  {
80  return EPlayerRole.ADMINISTRATOR | EPlayerRole.SESSION_ADMINISTRATOR | EPlayerRole.GAME_MASTER;
81  }
82 
83  override event bool IsServerSide()
84  {
85  return true;
86  }
87 }
EBCS_ERROR
@ EBCS_ERROR
Definition: UploadSaveCommand.c:5
m_eState
enum EBackendCallbackState m_eState
EBackendCallbackState
EBackendCallbackState
Definition: UploadSaveCommand.c:1
EPlayerRole
EPlayerRole
Definition: EPlayerRole.c:7
EBCS_SUCCESS
@ EBCS_SUCCESS
Definition: UploadSaveCommand.c:4
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
OnTimeout
override void OnTimeout()
Definition: UploadSaveCommand.c:23
ScrServerCmdResult
Definition: ScrServerCmdResult.c:7
EBCS_TIMEOUT
@ EBCS_TIMEOUT
Definition: UploadSaveCommand.c:6
OnSuccess
override void OnSuccess(int code)
Definition: UploadSaveCommand.c:18
ScrServerCommand
Definition: ScrServerCommand.c:7
BackendCallback
Base server browser callback.
Definition: SCR_ServerListComponent.c:4
OnError
override void OnError(int code, int restCode, int apiCode)
Definition: UploadSaveCommand.c:13
UploadSaveCommand
Definition: UploadSaveCommand.c:30
EBCS_PENDING
@ EBCS_PENDING
Definition: UploadSaveCommand.c:3