diff --git a/.gitignore b/.gitignore index 9a6cb9d..ed0a84e 100644 --- a/.gitignore +++ b/.gitignore @@ -404,4 +404,6 @@ FodyWeavers.xsd *.sln.iml # Hemtt -.hemttout/ \ No newline at end of file +.hemttout/ +.hemttprivatekey +.biprivatekey \ No newline at end of file diff --git a/ArmaDragonflyClient_x64.dll b/ArmaDragonflyClient_x64.dll index 43795ce..5797e5e 100644 Binary files a/ArmaDragonflyClient_x64.dll and b/ArmaDragonflyClient_x64.dll differ diff --git a/ArmaDragonflyClient_x64.so b/ArmaDragonflyClient_x64.so index 799f9f8..12796a7 100644 Binary files a/ArmaDragonflyClient_x64.so and b/ArmaDragonflyClient_x64.so differ diff --git a/addons/db/CfgEventHandlers.hpp b/addons/db/CfgEventHandlers.hpp index 78b189a..67fa1ae 100644 --- a/addons/db/CfgEventHandlers.hpp +++ b/addons/db/CfgEventHandlers.hpp @@ -16,4 +16,4 @@ class Extended_PostInit_EventHandlers { init = QUOTE(call COMPILE_FILE(XEH_postInit)); clientInit = QUOTE(call COMPILE_FILE(XEH_postInit_client)); }; -}; \ No newline at end of file +}; diff --git a/addons/db/XEH_PREP.hpp b/addons/db/XEH_PREP.hpp index d7c5390..cd143ae 100644 --- a/addons/db/XEH_PREP.hpp +++ b/addons/db/XEH_PREP.hpp @@ -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); \ No newline at end of file +PREP(test); diff --git a/addons/db/XEH_postInit.sqf b/addons/db/XEH_postInit.sqf index 02650ac..819a311 100644 --- a/addons/db/XEH_postInit.sqf +++ b/addons/db/XEH_postInit.sqf @@ -13,4 +13,4 @@ GVAR(taskQueue) = []; // hint "Function does not exist!" // }]); // }; -// }]; \ No newline at end of file +// }]; diff --git a/addons/db/XEH_postInit_client.sqf b/addons/db/XEH_postInit_client.sqf index 84f2529..421c54b 100644 --- a/addons/db/XEH_postInit_client.sqf +++ b/addons/db/XEH_postInit_client.sqf @@ -1 +1 @@ -#include "script_component.hpp" \ No newline at end of file +#include "script_component.hpp" diff --git a/addons/db/XEH_preInit.sqf b/addons/db/XEH_preInit.sqf index d7d59fe..ecb5d0c 100644 --- a/addons/db/XEH_preInit.sqf +++ b/addons/db/XEH_preInit.sqf @@ -5,4 +5,4 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; -ADDON = true; \ No newline at end of file +ADDON = true; diff --git a/addons/db/XEH_preInit_server.sqf b/addons/db/XEH_preInit_server.sqf index 4875e65..df700bd 100644 --- a/addons/db/XEH_preInit_server.sqf +++ b/addons/db/XEH_preInit_server.sqf @@ -3,4 +3,4 @@ addMissionEventHandler ["Ended", { "ArmaDragonflyClient" callExtension ["savedb", []]; INFO("Mission ended - forced save with backup"); -}]; \ No newline at end of file +}]; diff --git a/addons/db/XEH_preStart.sqf b/addons/db/XEH_preStart.sqf index 7dca066..a51262a 100644 --- a/addons/db/XEH_preStart.sqf +++ b/addons/db/XEH_preStart.sqf @@ -1,2 +1,2 @@ #include "script_component.hpp" -#include "XEH_PREP.hpp" \ No newline at end of file +#include "XEH_PREP.hpp" diff --git a/addons/db/config.cpp b/addons/db/config.cpp index 5eeb01a..397c156 100644 --- a/addons/db/config.cpp +++ b/addons/db/config.cpp @@ -13,4 +13,4 @@ class CfgPatches { }; }; -#include "CfgEventHandlers.hpp" \ No newline at end of file +#include "CfgEventHandlers.hpp" diff --git a/addons/db/script_component.hpp b/addons/db/script_component.hpp index 8def586..97a6c8c 100644 --- a/addons/db/script_component.hpp +++ b/addons/db/script_component.hpp @@ -13,4 +13,4 @@ #define DEBUG_SETTINGS DEBUG_SETTINGS_DB #endif -#include "..\main\script_macros.hpp" \ No newline at end of file +#include "..\main\script_macros.hpp" diff --git a/addons/main/CfgMods.hpp b/addons/main/CfgMods.hpp index 24fe04d..70db277 100644 --- a/addons/main/CfgMods.hpp +++ b/addons/main/CfgMods.hpp @@ -11,4 +11,4 @@ class CfgMods { description = "Innovative Dev Solutions"; dlcColor[] = {1, 0.0, 0.86, 1}; }; -}; \ No newline at end of file +}; diff --git a/addons/main/config.cpp b/addons/main/config.cpp index 3310382..1a60ae3 100644 --- a/addons/main/config.cpp +++ b/addons/main/config.cpp @@ -13,4 +13,4 @@ class CfgPatches { }; }; -#include "CfgMods.hpp" \ No newline at end of file +#include "CfgMods.hpp" diff --git a/addons/main/script_component.hpp b/addons/main/script_component.hpp index aa5f673..3179811 100644 --- a/addons/main/script_component.hpp +++ b/addons/main/script_component.hpp @@ -12,4 +12,4 @@ #define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN #endif -#include "\z\dragonfly\addons\main\script_macros.hpp" \ No newline at end of file +#include "\z\dragonfly\addons\main\script_macros.hpp" diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index 618a154..0e7a696 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -10,4 +10,4 @@ #else #undef PREP #define PREP(fncName) [QPATHTOF(functions\DOUBLES(fnc,fncName).sqf), QFUNC(fncName)] call CBA_fnc_compileFunction -#endif \ No newline at end of file +#endif diff --git a/addons/main/script_mod.hpp b/addons/main/script_mod.hpp index 0c6353e..3715042 100644 --- a/addons/main/script_mod.hpp +++ b/addons/main/script_mod.hpp @@ -12,4 +12,4 @@ #define COMPONENT_NAME QUOTE(DRAGONFLY - COMPONENT_BEAUTIFIED) #else #define COMPONENT_NAME QUOTE(DRAGONFLY - COMPONENT) -#endif \ No newline at end of file +#endif diff --git a/docs/core/init.md b/docs/core/init.md index e6ea870..be49316 100644 --- a/docs/core/init.md +++ b/docs/core/init.md @@ -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 diff --git a/extension/bin/Release/net8.0/linux-x64/publish/ArmaDragonflyClient_x64.so b/extension/bin/Release/net8.0/linux-x64/publish/ArmaDragonflyClient_x64.so new file mode 100644 index 0000000..12796a7 Binary files /dev/null and b/extension/bin/Release/net8.0/linux-x64/publish/ArmaDragonflyClient_x64.so differ diff --git a/extension/bin/Release/net8.0/win-x64/publish/ArmaDragonflyClient_x64.dll b/extension/bin/Release/net8.0/win-x64/publish/ArmaDragonflyClient_x64.dll new file mode 100644 index 0000000..5797e5e Binary files /dev/null and b/extension/bin/Release/net8.0/win-x64/publish/ArmaDragonflyClient_x64.dll differ diff --git a/extension/src/DragonflyDB.cs b/extension/src/DragonflyDB.cs index 5a36715..ac763f4 100644 --- a/extension/src/DragonflyDB.cs +++ b/extension/src/DragonflyDB.cs @@ -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 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 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; - } } } \ No newline at end of file diff --git a/extension/src/Main.cs b/extension/src/Main.cs index b2f659f..6c6eec7 100644 --- a/extension/src/Main.cs +++ b/extension/src/Main.cs @@ -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 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 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; - } - }); - } } } \ No newline at end of file diff --git a/extension/src/Utils.cs b/extension/src/Utils.cs index 8817874..e86045d 100644 --- a/extension/src/Utils.cs +++ b/extension/src/Utils.cs @@ -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); - } - } - } } } \ No newline at end of file diff --git a/mission/init.sqf b/mission/init.sqf deleted file mode 100644 index 7303960..0000000 --- a/mission/init.sqf +++ /dev/null @@ -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; diff --git a/mod.cpp b/mod.cpp index 2998bac..cc2a6ba 100644 --- a/mod.cpp +++ b/mod.cpp @@ -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"; \ No newline at end of file +actionName = "Website"; diff --git a/unlocks.txt b/unlocks.txt index 853875a..c07c8de 100644 --- a/unlocks.txt +++ b/unlocks.txt @@ -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"],[],[],[],[],[]] \ No newline at end of file +[["B_Quadbike_01_F"],[],[],[],[],[]]