WORKING: final bugfixes & add stored procedure for prev mission cleanup

This commit is contained in:
2023-06-22 10:27:09 -07:00
parent 3bb8c358fa
commit dbd3d68537
8 changed files with 153 additions and 97 deletions

View File

@@ -18,8 +18,8 @@ class CfgFunctions {
class eventHandlers {};
class callbackHandler {postInit = 1;};
class log {};
class logMissionEvent {};
class logServerEvent {};
class writeConnect {};
class writeDisconnect {};
class timestamp {};
class getMissionHash {};
class getWorldInfo {};

View File

@@ -46,6 +46,9 @@ addMissionEventHandler ["ExtensionCallback", {
[_response#0, _response#1, _function] call attendanceTracker_fnc_log;
if (_response#0 == "SUCCESS") then {
missionNamespace setVariable ["AttendanceTracker_DBConnected", true];
// close any null disconnect values from previous mission
"AttendanceTracker" callExtension ["fillLastMissionNull", []];
// log mission info and get back the row Id to send with future messages
private _response = "AttendanceTracker" callExtension [

View File

@@ -15,15 +15,16 @@
};
(AttendanceTracker getVariable ["allUsers", createHashMap]) set [_networkId, _userInfo];
(AttendanceTracker getVariable ["rowIds", createHashMap]) set [_networkId, [nil, nil]]; // reset rowId on connect
[
"Server",
_playerID,
_playerUID,
_profileName,
_steamName,
nil // send rowId on d/c only
] call attendanceTracker_fnc_logServerEvent;
nil,
nil
] call attendanceTracker_fnc_writeConnect;
}],
["OnUserDisconnected", {
@@ -45,19 +46,13 @@
[format ["(EventHandler) OnUserDisconnected: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
};
private _rowId = ((AttendanceTracker getVariable ["rowIds", createHashMap]) getOrDefault [
_networkId,
[nil, nil]
]) select 0;
[
"Server",
_playerID,
_playerUID,
_profileName,
_steamName,
(if (!isNil "_rowId") then {_rowId} else {nil}) // send rowId on d/c only
] call attendanceTracker_fnc_logServerEvent;
_steamName
] call attendanceTracker_fnc_writeDisconnect;
}],
["PlayerConnected", {
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
@@ -79,6 +74,7 @@
};
(AttendanceTracker getVariable ["allUsers", createHashMap]) set [_playerID, _userInfo];
[
"Mission",
_playerID,
@@ -86,9 +82,8 @@
_profileName,
_steamName,
_jip,
roleDescription _unit,
nil // send rowId on d/c only
] call attendanceTracker_fnc_logMissionEvent;
roleDescription _unit
] call attendanceTracker_fnc_writeConnect;
}],
["PlayerDisconnected", {
// NOTE: HandleDisconnect returns a DIFFERENT _id than PlayerDisconnected and above handlers, so we can't use it here
@@ -109,11 +104,6 @@
if (_isHC) exitWith {
[format ["(EventHandler) HandleDisconnect: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
};
private _rowId = ((AttendanceTracker getVariable ["rowIds", createHashMap]) getOrDefault [
_idstr,
[nil, nil]
]) select 1;
[
"Mission",
@@ -122,10 +112,8 @@
_profileName,
_steamName,
_jip,
nil,
(if (!isNil "_rowId") then {_rowId} else {nil}) // send rowId on d/c only
] call attendanceTracker_fnc_logMissionEvent;
nil
] call attendanceTracker_fnc_writeDisconnect;
false;
}],
@@ -149,32 +137,24 @@
[format ["(EventHandler) OnUserKicked: %1 is HC, skipping", _playerID], "DEBUG"] call attendanceTracker_fnc_log;
};
private _rowId = ((AttendanceTracker getVariable ["rowIds", createHashMap]) getOrDefault [
_networkId,
[nil, nil]
]) select 0;
[
"Server",
_playerID,
_playerUID,
_profileName,
_steamName,
(if (!isNil "_rowId") then {_rowId} else {nil}) // send rowId on d/c only
] call attendanceTracker_fnc_logServerEvent;
nil,
nil
] call attendanceTracker_fnc_writeDisconnect;
private _rowId = ((AttendanceTracker getVariable ["rowIds", createHashMap]) getOrDefault [
_networkId,
[nil, nil]
]) select 1;
[
"Mission",
_playerID,
_playerUID,
_profileName,
_steamName,
nil // send rowId on d/c only
] call attendanceTracker_fnc_logMissionEvent;
nil,
nil
] call attendanceTracker_fnc_writeDisconnect;
}]
];

View File

@@ -5,11 +5,11 @@ params [
["_profileName", ""],
["_steamName", ""],
["_isJIP", false, [true, false]],
["_roleDescription", ""],
["_rowID", nil]
["_roleDescription", ""]
];
private _hash = + (AttendanceTracker getVariable ["missionContext", createHashMap]);
_hash set ["eventType", _eventType];
_hash set ["playerId", _playerId];
_hash set ["playerUID", _playerUID];
@@ -19,11 +19,6 @@ _hash set ["isJIP", _isJIP];
_hash set ["roleDescription", _roleDescription];
_hash set ["missionHash", missionNamespace getVariable ["AttendanceTracker_missionHash", ""]];
if (!isNil "_rowID") then {
_hash set ["rowID", _rowID];
"AttendanceTracker" callExtension ["writeDisconnectEvent", [[_hash] call CBA_fnc_encodeJSON]];
} else {
"AttendanceTracker" callExtension ["writeAttendance", [[_hash] call CBA_fnc_encodeJSON]];
};
"AttendanceTracker" callExtension ["writeAttendance", [[_hash] call CBA_fnc_encodeJSON]];
true;

View File

@@ -4,26 +4,21 @@ params [
["_playerUID", ""],
["_profileName", ""],
["_steamName", ""],
["_rowID", nil]
["_isJIP", false, [true, false]],
["_roleDescription", ""]
];
private _hash = + (AttendanceTracker getVariable ["missionContext", createHashMap]);
_hash set ["networkId", netID player];
_hash set ["eventType", _eventType];
_hash set ["playerId", _playerId];
_hash set ["playerUID", _playerUID];
_hash set ["profileName", _profileName];
_hash set ["steamName", _steamName];
_hash set ["isJIP", false];
_hash set ["roleDescription", ""];
_hash set ["isJIP", _isJIP];
_hash set ["roleDescription", _roleDescription];
_hash set ["missionHash", missionNamespace getVariable ["AttendanceTracker_missionHash", ""]];
if (!isNil "_rowID") then {
_hash set ["rowID", _rowID];
"AttendanceTracker" callExtension ["writeDisconnectEvent", [[_hash] call CBA_fnc_encodeJSON]];
} else {
"AttendanceTracker" callExtension ["writeAttendance", [[_hash] call CBA_fnc_encodeJSON]];
};
"AttendanceTracker" callExtension ["writeDisconnectEvent", [[_hash] call CBA_fnc_encodeJSON]];
true;