add mission md5 hash as unique id, break out db connect ask, add world

This commit is contained in:
2023-05-08 00:15:27 -07:00
parent f8714b7012
commit 43aa384949
9 changed files with 194 additions and 24 deletions

View File

@@ -39,6 +39,21 @@ addMissionEventHandler ["ExtensionCallback", {
case "connectDB": {
systemChat format ["AttendanceTracker: %1", _response#0];
[_response#0, _response#1, _function] call attendanceTracker_fnc_log;
if (_response#0 == "SUCCESS") then {
missionNamespace setVariable ["AttendanceTracker_DBConnected", true];
// log mission info and get back the row Id to send with future messages
private _response = "AttendanceTracker" callExtension ["logMission", [
[AttendanceTracker getVariable ["missionContext", createHashMap]] call CBA_fnc_encodeJSON
]];
AttendanceTracker_missionId = parseNumber _response;
// log world info
private _response = "AttendanceTracker" callExtension ["logWorld", [
[call attendanceTracker_fnc_getWorldInfo] call CBA_fnc_encodeJSON
]];
};
};
default {
_response call attendanceTracker_fnc_log;

View File

@@ -0,0 +1,3 @@
private _database = "AttendanceTracker" callExtension "connectDB";
// systemChat "AttendanceTracker: Connecting to database...";
["Connecting to database...", "INFO"] call attendanceTracker_fnc_log;

View File

@@ -0,0 +1,23 @@
_world = ( configfile >> "CfgWorlds" >> worldName );
_author = getText( _world >> "author" );
_name = getText ( _world >> "description" );
_source = configSourceMod ( _world );
_workshopID = '';
{
if ( ( _x#1 ) == _source ) then {
_workshopID = _x#7;
break;
};
} foreach getLoadedModsInfo;
// [_name, _author, _workshopID];
[
["worldName", _name],
["author", _author],
["worldSize", worldSize],
["workshopID", _workshopID]
];

View File

@@ -16,6 +16,7 @@ _hash set ["profileName", _profileName];
_hash set ["steamName", _steamName];
_hash set ["isJIP", _isJIP];
_hash set ["roleDescription", _roleDescription];
_hash set ["missionHash", missionNamespace getVariable ["AttendanceTracker_missionHash", ""]];
"AttendanceTracker" callExtension ["logAttendance", [[_hash] call CBA_fnc_encodeJSON]];

View File

@@ -15,6 +15,7 @@ _hash set ["profileName", _profileName];
_hash set ["steamName", _steamName];
_hash set ["isJIP", false];
_hash set ["roleDescription", ""];
_hash set ["missionHash", missionNamespace getVariable ["AttendanceTracker_missionHash", ""]];
"AttendanceTracker" callExtension ["logAttendance", [[_hash] call CBA_fnc_encodeJSON]];

View File

@@ -1,6 +1,9 @@
AttendanceTracker = false call CBA_fnc_createNamespace;
AttendanceTracker_missionStartTimestamp = call attendanceTracker_fnc_timestamp;
AttendanceTracker_missionHash = "AttendanceTracker" callExtension ["getMissionHash", AttendanceTracker_missionStartTimestamp];
AttendanceTracker setVariable ["missionContext", createHashMapFromArray [
["missionName", missionName],
["briefingName", briefingName],
@@ -9,16 +12,17 @@ AttendanceTracker setVariable ["missionContext", createHashMapFromArray [
["author", getMissionConfigValue ["author", ""]],
["serverName", serverName],
["serverProfile", profileName],
["missionStart", call attendanceTracker_fnc_timestamp]
["missionStart", AttendanceTracker_missionStartTimestamp],
["missionHash", AttendanceTracker_missionHash]
]];
// store all user details in a hash when they connect so we can reference it in disconnect events
AttendanceTracker setVariable ["allUsers", createHashMap];
missionNamespace getVariable ["AttendanceTracker_debug", false];
missionNamespace setVariable ["AttendanceTracker_debug", false];
private _database = "AttendanceTracker" callExtension "connectDB";
// systemChat "AttendanceTracker: Connecting to database...";
["Connecting to database...", "INFO"] call attendanceTracker_fnc_log;
call attendanceTracker_fnc_connectDB;
{
if (!isServer) exitWith {};