fix RPT spam, allow re-init of capture, change to spawn loop, fix setvar
- add readme too
This commit is contained in:
@@ -31,7 +31,6 @@ try {
|
||||
|
||||
switch (_function) do {
|
||||
case "deinitExtension": {
|
||||
diag_log format ["RangerMetrics: deinitExtension: %1", _response];
|
||||
// Our first call is deinitExtension. When we received a single "true" value, we can then run init processes for the extension connections.
|
||||
if ((_response select 0) isEqualTo true) then {
|
||||
"RangerMetrics" callExtension "initExtension";
|
||||
@@ -46,6 +45,39 @@ switch (_function) do {
|
||||
// Load settings
|
||||
[_function, _response] call RangerMetrics_callback_fnc_loadSettings;
|
||||
};
|
||||
case "extensionReady": {
|
||||
// deinitialize existing captures
|
||||
if (!isNil "RangerMetrics_allMEH") then {
|
||||
{
|
||||
private _handle = missionNamespace getVariable _x;
|
||||
if (isNil "_handle") then {continue};
|
||||
private _EHName = (_x splitString "_") select 2;
|
||||
removeMissionEventHandler [_EHName, _handle];
|
||||
missionNamespace setVariable [_x, nil];
|
||||
} forEach RangerMetrics_allMEH;
|
||||
};
|
||||
|
||||
if (!isNil "RangerMetrics_allCBA") then {
|
||||
{
|
||||
private _handle = missionNamespace getVariable _x;
|
||||
if (isNil "_handle") then {continue};
|
||||
private _EHName = (_x splitString "_") select 2;
|
||||
[_EHName, _handle] call CBA_fnc_removeEventHandler;
|
||||
missionNamespace setVariable [_x, nil];
|
||||
} forEach RangerMetrics_allCBA;
|
||||
};
|
||||
|
||||
if (!isNil "RangerMetrics_allServerPoll") then {
|
||||
{
|
||||
private _handle = missionNamespace getVariable _x;
|
||||
if (isNil "_handle") then {continue};
|
||||
terminate _handle;
|
||||
missionNamespace setVariable [_x, nil];
|
||||
} forEach RangerMetrics_allServerPoll;
|
||||
};
|
||||
|
||||
call RangerMetrics_fnc_initCapture;
|
||||
};
|
||||
default {
|
||||
_response call RangerMetrics_fnc_log;
|
||||
};
|
||||
|
||||
@@ -16,10 +16,12 @@ if (_function isEqualTo "loadSettingsJSON") exitWith {
|
||||
] call RangerMetrics_fnc_log;
|
||||
|
||||
if (isServer) then {
|
||||
RangerMetrics_serverProfileName = profileName;
|
||||
publicVariable "RangerMetrics_serverProfileName";
|
||||
missionNamespace setVariable [
|
||||
"RangerMetrics_serverProfileName",
|
||||
profileName,
|
||||
true
|
||||
];
|
||||
};
|
||||
call RangerMetrics_fnc_initCapture;
|
||||
};
|
||||
|
||||
switch (_data select 0) do {
|
||||
|
||||
@@ -69,7 +69,7 @@
|
||||
false;
|
||||
} else {
|
||||
missionNamespace setVariable [
|
||||
("RangerMetrics" + "_CBAEH_" + _settingName),
|
||||
("RangerMetrics" + "_CBAEH_" + _handleName),
|
||||
_handle
|
||||
];
|
||||
true;
|
||||
@@ -81,24 +81,24 @@
|
||||
|
||||
|
||||
|
||||
private _meh = allVariables missionNamespace select {
|
||||
RangerMetrics_allMEH = allVariables missionNamespace select {
|
||||
_x find (toLower "RangerMetrics_MEH_") == 0
|
||||
};
|
||||
private _cba = allVariables missionNamespace select {
|
||||
RangerMetrics_allCBA = allVariables missionNamespace select {
|
||||
_x find (toLower "RangerMetrics_CBAEH_") == 0
|
||||
};
|
||||
private _serverPoll = allVariables missionNamespace select {
|
||||
RangerMetrics_allServerPoll = allVariables missionNamespace select {
|
||||
_x find (toLower "RangerMetrics_serverPoll_") == 0
|
||||
};
|
||||
|
||||
[format ["Mission event handlers: %1", _meh]] call RangerMetrics_fnc_log;
|
||||
[format ["CBA event handlers: %1", _cba]] call RangerMetrics_fnc_log;
|
||||
[format ["Server poll handles: %1", _serverPoll]] call RangerMetrics_fnc_log;
|
||||
[format ["Mission event handlers: %1", RangerMetrics_allMEH]] call RangerMetrics_fnc_log;
|
||||
[format ["CBA event handlers: %1", RangerMetrics_allCBA]] call RangerMetrics_fnc_log;
|
||||
[format ["Server poll handles: %1", RangerMetrics_allServerPoll]] call RangerMetrics_fnc_log;
|
||||
|
||||
|
||||
RangerMetrics_initialized = true;
|
||||
RangerMetrics_run = true;
|
||||
["RangerMetrics_run", true] remoteExecCall ["setVariable", 0];
|
||||
missionNamespace setVariable ["RangerMetrics_initialized", true, true];
|
||||
missionNamespace setVariable ["RangerMetrics_run", true, true];
|
||||
|
||||
|
||||
|
||||
// start sending
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
params [["_text","Log text invalid"], ["_type","INFO"]];
|
||||
params [["_text","Log text invalid"], ["_logType","DEBUG"]];
|
||||
|
||||
if (typeName _this != "ARRAY") exitWith {
|
||||
diag_log format ["RangerMetrics: Invalid log params: %1", _this];
|
||||
@@ -6,18 +6,19 @@ if (typeName _this != "ARRAY") exitWith {
|
||||
if (typeName _text != "STRING") exitWith {
|
||||
diag_log format ["RangerMetrics: Invalid log text: %1", _this];
|
||||
};
|
||||
if (typeName _type != "STRING") exitWith {
|
||||
if (typeName _logType != "STRING") exitWith {
|
||||
diag_log format ["RangerMetrics: Invalid log type: %1", _this];
|
||||
};
|
||||
|
||||
if (_type isEqualTo "DEBUG") then {
|
||||
if (!RangerMetrics_debug) exitWith {};
|
||||
};
|
||||
if (
|
||||
_logType == "DEBUG" &&
|
||||
!(missionNamespace getVariable ["RangerMetrics_debug", false])
|
||||
) exitWith {};
|
||||
|
||||
private _textFormatted = format [
|
||||
"[%1] %2: %3",
|
||||
RangerMetrics_logPrefix,
|
||||
_type,
|
||||
_logType,
|
||||
_text];
|
||||
|
||||
if(isServer) then {
|
||||
|
||||
@@ -20,7 +20,7 @@ RangerMetrics_recordingSettings = createHashMap;
|
||||
|
||||
[format ["Instance name: %1", profileName]] call RangerMetrics_fnc_log;
|
||||
[format ["CBA detected: %1", RangerMetrics_cbaPresent]] call RangerMetrics_fnc_log;
|
||||
["Initializing v0.1"] call RangerMetrics_fnc_log;
|
||||
["Initializing v0.0.2"] call RangerMetrics_fnc_log;
|
||||
|
||||
// Create listener - extension calls are async, so we need to listen for the response
|
||||
addMissionEventHandler [
|
||||
|
||||
@@ -21,7 +21,17 @@ if (_tagContext find "world" > -1) then {
|
||||
_tags pushBack ["string", "world", toLower worldName];
|
||||
};
|
||||
if (_tagContext find "server" > -1) then {
|
||||
_tags pushBack ["string", "connectedServer", RangerMetrics_serverProfileName];
|
||||
private _serverProfile = missionNamespace getVariable [
|
||||
"RangerMetrics_serverProfileName",
|
||||
""
|
||||
];
|
||||
if (_serverProfile isNotEqualTo "") then {
|
||||
_tags pushBack [
|
||||
"string",
|
||||
"connectedServer",
|
||||
_serverProfile
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
private _outTags = _tags apply {
|
||||
|
||||
@@ -12,16 +12,41 @@ if (_interval == 0) exitWith {
|
||||
[_code] call CBA_fnc_execNextFrame;
|
||||
};
|
||||
|
||||
|
||||
private _handle = [{
|
||||
params ["_args", "_idPFH"];
|
||||
_args params ["_refName", "_code"];
|
||||
|
||||
[_code] call CBA_fnc_execNextFrame;
|
||||
|
||||
}, _interval, _this] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// run a constant scheduled loop
|
||||
private _runnerVar = "RangerMetrics" + "_serverPollRunner_" + _refName;
|
||||
missionNamespace setVariable [_runnerVar, scriptNull];
|
||||
private _spawnParams = [_refName, _code, _interval, _runnerVar];
|
||||
private _handle = _spawnParams spawn {
|
||||
params ["_refName", "_code", "_interval", "_runnerVar"];
|
||||
while {true} do {
|
||||
if (scriptDone (
|
||||
missionNamespace getVariable _runnerVar
|
||||
)) then {
|
||||
private _handle = [] spawn _code;
|
||||
missionNamespace setVariable [
|
||||
_runnerVar,
|
||||
_handle
|
||||
];
|
||||
};
|
||||
// sleep _interval;
|
||||
sleep 2;
|
||||
};
|
||||
};
|
||||
missionNamespace setVariable [
|
||||
"RangerMetrics" + "_serverPoll_" + _refName,
|
||||
_handle
|
||||
];
|
||||
];
|
||||
|
||||
// USE PFH
|
||||
// private _handle = [{
|
||||
// params ["_args", "_idPFH"];
|
||||
// _args params ["_refName", "_code"];
|
||||
|
||||
// [_code] call CBA_fnc_execNextFrame;
|
||||
|
||||
// }, _interval, _this] call CBA_fnc_addPerFrameHandler;
|
||||
|
||||
// missionNamespace setVariable [
|
||||
// "RangerMetrics" + "_serverPoll_" + _refName,
|
||||
// _handle
|
||||
// ];
|
||||
Reference in New Issue
Block a user