Refactor event listener registration and update logging settings for task events

This commit is contained in:
Jacob Schmidt 2026-05-15 20:22:42 -05:00
parent 27c3c5e502
commit b1959ee06d
7 changed files with 46 additions and 11 deletions

View File

@ -5,4 +5,4 @@ PREP(initGroupRepository);
PREP(initPermissionService);
PREP(initPersistenceService);
PREP(initRequestRepository);
PREP(registerTaskEventListeners);
PREP(registerEventListeners);

View File

@ -5,7 +5,7 @@ PREP_RECOMPILE_START;
PREP_RECOMPILE_END;
call FUNC(initCadStore);
call FUNC(registerTaskEventListeners);
call FUNC(registerEventListeners);
[QGVAR(requestHydrateCad), {
params [["_uid", "", [""]]];

View File

@ -1,13 +1,13 @@
#include "..\script_component.hpp"
/*
* File: fnc_registerTaskEventListeners.sqf
* File: fnc_registerEventListeners.sqf
* Author: IDSolutions
* Date: 2026-05-14
* Public: No
*
* Description:
* Registers CAD listeners for framework task lifecycle events.
* Registers CAD listeners for framework events that should refresh CAD state.
*
* Arguments:
* None
@ -16,7 +16,7 @@
* Listener tokens [ARRAY]
*
* Example:
* call forge_server_cad_fnc_registerTaskEventListeners
* call forge_server_cad_fnc_registerEventListeners
*/
if (isNil QEGVAR(common,EventBus)) then { call EFUNC(common,eventBus); };

View File

@ -43,6 +43,41 @@ Payloads should be hash maps and should include stable identifiers first:
`taskID`, `requestID`, `groupID`, `uid`, `orgID`, or `accountID` as appropriate.
The event bus adds `event`, `source`, and `timestamp` when the event is emitted.
### Current Events
Task lifecycle:
- `task.created`
- `task.started`
- `task.completed`
- `task.failed`
- `task.cleared`
Task rewards and notifications:
- `task.reward.requested`
- `task.reward.applied`
- `task.reward.failed`
- `task.rating.applied`
- `task.rating.failed`
- `task.notification.requested`
- `task.reward.notification.requested`
CAD state:
- `cad.assignment.assigned`
- `cad.assignment.created`
- `cad.assignment.acknowledged`
- `cad.assignment.declined`
- `cad.assignment.closed`
- `cad.request.submitted`
- `cad.request.closed`
- `cad.group.updated`
Client sync and notification requests:
- `notification.requested`
- `bank.account.sync.requested`
- `org.sync.requested`
- `locker.sync.requested`
- `locker.va.sync.requested`
- `garage.vgarage.sync.requested`
```sqf
private _token = EGVAR(common,EventBus) call ["on", [
"task.completed",

View File

@ -5,7 +5,7 @@ if (isNil QGVAR(TaskLifecycleEventLogTokens)) then {
private _logTaskLifecycleEvent = {
params ["_event"];
if !(missionNamespace getVariable [QGVAR(enableEventLogs), true]) exitWith {};
if !(missionNamespace getVariable [QGVAR(enableEventLogs), false]) exitWith {};
["INFO", format [
"Task lifecycle event: %1 taskID=%2 taskType=%3 status=%4 participants=%5",
@ -20,7 +20,7 @@ if (isNil QGVAR(TaskLifecycleEventLogTokens)) then {
private _logTaskRewardEvent = {
params ["_event"];
if !(missionNamespace getVariable [QGVAR(enableEventLogs), true]) exitWith {};
if !(missionNamespace getVariable [QGVAR(enableEventLogs), false]) exitWith {};
["INFO", format [
"Task reward event: %1 taskID=%2 success=%3 message=%4",
@ -62,7 +62,7 @@ if (isNil QGVAR(TaskNotificationEventTokens)) then {
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
} forEach _participantUids;
if (missionNamespace getVariable [QGVAR(enableEventLogs), true]) then {
if (missionNamespace getVariable [QGVAR(enableEventLogs), false]) then {
["INFO", format [
"Task notification event: taskID=%1 type=%2 recipients=%3 message=%4",
_event getOrDefault ["taskID", ""],
@ -89,7 +89,7 @@ if (isNil QGVAR(TaskNotificationEventTokens)) then {
[CRPC(notifications,recieveNotification), [_type, _title, _message], _player] call CFUNC(targetEvent);
} forEach _memberUids;
if (missionNamespace getVariable [QGVAR(enableEventLogs), true]) then {
if (missionNamespace getVariable [QGVAR(enableEventLogs), false]) then {
["INFO", format [
"Task reward notification event: taskID=%1 type=%2 recipients=%3 message=%4",
_event getOrDefault ["taskID", ""],

View File

@ -7,5 +7,5 @@
[
QGVAR(enableEventLogs), "CHECKBOX",
[LSTRING(enableEventLogs), LSTRING(enableEventLogsTooltip)],
_category, true, true
_category, false, true
] call CBA_fnc_addSetting;

View File

@ -8,7 +8,7 @@
<English>Enable Event Logs</English>
</Key>
<Key ID="STR_forge_server_task_enableEventLogsTooltip">
<English>Log task event bus lifecycle, reward, rating, and notification events.</English>
<English>Log task event bus lifecycle, reward, rating, and notification events for debugging.</English>
</Key>
<Key ID="STR_forge_server_task_enableGenerator">
<English>Enable Generator</English>