Skip to content

Commit 8a90c1d

Browse files
committed
feat(extension): handle :MISSION:SAVED: async callback
1 parent 502df91 commit 8a90c1d

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

addons/extension/fnc_initSession.sqf

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,49 @@ addMissionEventHandler ["ExtensionCallback", {
154154
INFO("Mission registered. Starting data send.");
155155
GVAR(sessionReady) = true;
156156
};
157+
158+
if (_function isEqualTo ":MISSION:SAVED:") exitWith {
159+
// Payload shapes:
160+
// ["ok", path]
161+
// ["partial", path, error]
162+
// ["error", error]
163+
private _status = _data param [0, ""];
164+
private _detail = _data param [1, ""];
165+
private _extra = _data param [2, ""];
166+
167+
switch (_status) do {
168+
case "ok": {
169+
INFO_1("Mission save complete — path: %1",_detail);
170+
GVAR(lastSaveResult) = ["ok", _detail];
171+
[
172+
format["OCAP saved %1 successfully", briefingName],
173+
2,
174+
[0, 0.8, 0, 1]
175+
] remoteExec ["CBA_fnc_notify", [0, -2] select isDedicated];
176+
};
177+
case "partial": {
178+
WARNING_2("Mission save complete but upload failed — path: %1 error: %2",_detail,_extra);
179+
GVAR(lastSaveResult) = ["partial", _detail, _extra];
180+
[
181+
format["OCAP saved locally (%1) but upload failed: %2", _detail, _extra],
182+
2,
183+
[1, 0.8, 0, 1]
184+
] remoteExec ["CBA_fnc_notify", [0, -2] select isDedicated];
185+
};
186+
case "error": {
187+
ERROR_MSG_1("Mission save failed: %1",_detail);
188+
GVAR(lastSaveResult) = ["error", _detail];
189+
[
190+
format["OCAP save failed: %1", _detail],
191+
2,
192+
[1, 0, 0, 1]
193+
] remoteExec ["CBA_fnc_notify", [0, -2] select isDedicated];
194+
};
195+
default {
196+
WARNING_1("Unknown :MISSION:SAVED: status: %1",_status);
197+
};
198+
};
199+
};
157200
}];
158201

159202

0 commit comments

Comments
 (0)