Commit remaining changes

This commit is contained in:
Jacob Schmidt 2026-01-13 20:20:28 -06:00
parent d6f9923eb5
commit d7138d4f1f
26 changed files with 21 additions and 195 deletions

4
.gitignore vendored
View File

@ -404,4 +404,6 @@ FodyWeavers.xsd
*.sln.iml
# Hemtt
.hemttout/
.hemttout/
.hemttprivatekey
.biprivatekey

Binary file not shown.

Binary file not shown.

View File

@ -16,4 +16,4 @@ class Extended_PostInit_EventHandlers {
init = QUOTE(call COMPILE_FILE(XEH_postInit));
clientInit = QUOTE(call COMPILE_FILE(XEH_postInit_client));
};
};
};

View File

@ -19,13 +19,9 @@ PREP(listGet);
PREP(listLoad);
PREP(listRemove);
PREP(listSet);
PREP(pubSubFetch);
PREP(pubSubHandler);
PREP(processQueue);
PREP(publish);
PREP(saveDB);
PREP(scheduler);
PREP(set);
PREP(setup);
PREP(subscribe);
PREP(test);
PREP(test);

View File

@ -13,4 +13,4 @@ GVAR(taskQueue) = [];
// hint "Function does not exist!"
// }]);
// };
// }];
// }];

View File

@ -1 +1 @@
#include "script_component.hpp"
#include "script_component.hpp"

View File

@ -5,4 +5,4 @@ PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;
ADDON = true;
ADDON = true;

View File

@ -3,4 +3,4 @@
addMissionEventHandler ["Ended", {
"ArmaDragonflyClient" callExtension ["savedb", []];
INFO("Mission ended - forced save with backup");
}];
}];

View File

@ -1,2 +1,2 @@
#include "script_component.hpp"
#include "XEH_PREP.hpp"
#include "XEH_PREP.hpp"

View File

@ -13,4 +13,4 @@ class CfgPatches {
};
};
#include "CfgEventHandlers.hpp"
#include "CfgEventHandlers.hpp"

View File

@ -13,4 +13,4 @@
#define DEBUG_SETTINGS DEBUG_SETTINGS_DB
#endif
#include "..\main\script_macros.hpp"
#include "..\main\script_macros.hpp"

View File

@ -11,4 +11,4 @@ class CfgMods {
description = "Innovative Dev Solutions";
dlcColor[] = {1, 0.0, 0.86, 1};
};
};
};

View File

@ -13,4 +13,4 @@ class CfgPatches {
};
};
#include "CfgMods.hpp"
#include "CfgMods.hpp"

View File

@ -12,4 +12,4 @@
#define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN
#endif
#include "\z\dragonfly\addons\main\script_macros.hpp"
#include "\z\dragonfly\addons\main\script_macros.hpp"

View File

@ -10,4 +10,4 @@
#else
#undef PREP
#define PREP(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNC(fncName)] call CBA_fnc_compileFunction
#endif
#endif

View File

@ -12,4 +12,4 @@
#define COMPONENT_NAME QUOTE(DRAGONFLY - COMPONENT_BEAUTIFIED)
#else
#define COMPONENT_NAME QUOTE(DRAGONFLY - COMPONENT)
#endif
#endif

View File

@ -24,7 +24,7 @@ None. The function sets up internal variables and logs initialization informatio
This function is automatically executed during framework initialization and doesn't need to be called manually.
## Notes
- Sets the global buffer size to 10240 bytes (10KB)
- Sets the global buffer size to 20480 bytes (10KB)
- Logs the DLL version number for reference
- Confirms successful loading of all functions
- Outputs initialization status to the RPT logs

View File

@ -5,7 +5,6 @@ namespace ArmaDragonflyClient
internal class DragonflyDB
{
private readonly static DragonflyClient _client = new(Main.ADC_HOST, Main.ADC_PORT, Main.ADC_PASSWORD);
private static CancellationTokenSource _listenerCts;
public static async Task<string> DragonflyRaw(string key, string keyValue, string function = null)
{
@ -167,76 +166,5 @@ namespace ArmaDragonflyClient
string response = await _client.SendCommandAsync("SAVE");
Main.Log($"ArmaDragonflyClient 'SAVE', Response: '{response}'", "debug");
}
public static async Task DragonflyPublishAsync(string channel, string message, string uniqueID)
{
await _client.ConnectAsync();
await _client.SendCommandAsync($"PUBLISH {channel} {message}");
Main.Log($"ArmaDragonflyClient 'PUBLISH', Channel: '{channel}', Message: '{message}'", "debug");
}
public static async Task DragonflySubscribeAsync(string channel, string eventType, string eventName, string uniqueID, string target = null, int bufferSize = Main.ADC_BUFFERSIZE)
{
await _client.ConnectAsync();
try
{
await _client.SendCommandAsync($"SUBSCRIBE {channel}");
Main.Log($"ArmaDragonflyClient 'SUBSCRIBE', Channel: '{channel}'", "debug");
_listenerCts = new CancellationTokenSource();
await Task.Run(async () =>
{
await StartMessageListener(message => {
Utils.CheckByteCountPubSub(uniqueID, message, eventType, eventName, target, bufferSize);
});
});
}
catch (Exception ex)
{
Main.Log($"ArmaDragonflyClient 'SUBSCRIBE', Exception: '{ex.Message}'", "error");
throw;
}
}
private static async Task StartMessageListener(Action<string> messageHandler)
{
try
{
while (!_listenerCts.Token.IsCancellationRequested)
{
string response = await _client.ReceiveMessageAsync();
if (!string.IsNullOrEmpty(response))
{
var messageParts = response.Split(',');
if (messageParts.Length >= 3)
{
string messageType = messageParts[0];
string channel = messageParts[1];
string message = messageParts[2];
Main.Log($"ArmaDragonflyClient 'SUBSCRIBE', Channel: '{channel}', Message: '{message}'", "debug");
messageHandler(message);
}
}
await Task.Delay(10);
}
}
catch (Exception ex)
{
Main.Log($"ArmaDragonflyClient 'SUBSCRIBE', Exception: '{ex.Message}'", "error");
throw;
}
}
public static void StopMessageListener()
{
_listenerCts.Cancel();
_listenerCts.Dispose();
_listenerCts = null;
}
}
}

View File

@ -18,7 +18,7 @@ namespace ArmaDragonflyClient
public class Main
{
private const string ADC_VERSION = "1.0.0";
public const int ADC_BUFFERSIZE = 10240;
public const int ADC_BUFFERSIZE = 20480;
public static string ADC_HOST {get; private set; } = "127.0.0.1";
public static int ADC_PORT {get; private set; } = 6379;
public static string ADC_PASSWORD {get; private set; } = "xyz123";
@ -276,14 +276,6 @@ namespace ArmaDragonflyClient
HandleHDelIdOperation(argsArr);
WriteOutput(output, "Async");
return 200;
case "publish":
HandlePublishOperation(_id, argsArr);
WriteOutput(output, $"[\"{_id}_publish\"]");
return 100;
case "subscribe":
HandleSubscribeOperation(_id, argsArr, argc);
WriteOutput(output, $"[\"{_id}_subscribe\"]");
return 100;
case "savedb":
HandleSaveDBOperation();
WriteOutput(output, "Async");
@ -623,31 +615,5 @@ namespace ArmaDragonflyClient
Log($"DragonflyDB connection settings updated - Host: '{host}', Port: '{port}', Password: '{password}'", "action");
}
private static void HandlePublishOperation(long _id, List<string> argsArr)
{
Task.Run(async () =>
{
string _uniqueID = $"{_id}_publish";
await DragonflyDB.DragonflyPublishAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID);
});
}
private static void HandleSubscribeOperation(long _id, List<string> argsArr, int argsCnt)
{
Task.Run(async () =>
{
string _uniqueID = $"{_id}_subscribe";
switch (argsCnt)
{
case 3:
await DragonflyDB.DragonflySubscribeAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID);
break;
case 4:
await DragonflyDB.DragonflySubscribeAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID, argsArr[3].Trim('"'));
break;
}
});
}
}
}

View File

@ -78,40 +78,5 @@ namespace ArmaDragonflyClient
}
}
}
public static void CheckByteCountPubSub(string uniqueId, string data, string eventType, string eventName, string target, int bufferSize)
{
if (Encoding.UTF8.GetByteCount(data) <= bufferSize)
{
if (!data.StartsWith('['))
data = BuildArray(data);
Main.Log($"Single chunk data: {data}", "debug");
string dataAsString = $"[\"{uniqueId}\",\"{eventType}\",\"{eventName}\",{data},\"{target}\"]";
Main.Log($"Single chunk data: {dataAsString}", "debug");
Main.Callback("ArmaDragonflyClient", "dragonfly_db_fnc_pubSubHandler", dataAsString);
}
else
{
if (!data.StartsWith('['))
data = BuildArray(data);
Main.Log($"Single chunk data: {data}", "debug");
var chunks = SplitIntoChunks(data, bufferSize);
int totalChunks = chunks.Count;
for (int chunkIndex = 0; chunkIndex < chunks.Count; chunkIndex++)
{
string escapedChunkData = chunks[chunkIndex].Replace("\"", "\"\"");
string chunkAsString = $"[\"{uniqueId}\",\"{eventType}\",\"{eventName}\",{chunkIndex+1},{totalChunks},\"{escapedChunkData}\",\"{target}\"]";
Main.Log($"Chunk {chunkIndex+1}/{totalChunks}: {chunkAsString}", "debug");
Main.Callback("ArmaDragonflyClient", "dragonfly_db_fnc_pubSubFetch", chunkAsString);
}
}
}
}
}

View File

@ -1,31 +0,0 @@
writeLog = {
diag_log format ["[ArmaExtensionDotNet] LOG: %1", _this];
};
execSqf = {
_this spawn {
"ArmaExtensionDotNet" callExtension ["sendResponse", [call compile _this]];
};
};
addMissionEventHandler [
"ExtensionCallback",
{
params ["_name", "_function", "_data"];
diag_log format["ExtensionCallback - name: '%1', function: '%2', data: '%3'", _name, _function, _data];
if (_name isEqualTo "ArmaExtensionDotNet") then {
_func = missionNamespace getVariable [_function, objNull];
if (_func isEqualTo objNull) then {
hint "Function does not exist!";
} else {
_data call _func;
};
};
}
];
_result = "ArmaExtensionDotNet" callExtension "runSqfTest";
systemChat _result;

View File

@ -9,4 +9,4 @@ tooltipOwned = "ArmaDragonflyClient";
overview = "IDSolutions ArmaDragonflyClient - Official Modification";
description = "IDS Dragonfly - Version 1.0.0";
action = "https://github.com/jschmidt92/ArmaDragonflyClient";
actionName = "Website";
actionName = "Website";

View File

@ -1,2 +1,2 @@
[["SOG_Phone", "SOG_Tablet", "ItemCompass", "ItemGPS", "ItemMap", "ItemRadio", "ItemWatch", "U_BG_Guerrilla_6_1", "V_Rangemaster_belt"],["hgun_P07_F"],["16Rnd_9x21_Mag"],[]]
[["B_Quadbike_01_F"],[],[],[],[],[]]
[["B_Quadbike_01_F"],[],[],[],[],[]]