diff --git a/ArmaDragonflyClient_x64.dll b/ArmaDragonflyClient_x64.dll index 2af4bd2..640ee2d 100644 Binary files a/ArmaDragonflyClient_x64.dll and b/ArmaDragonflyClient_x64.dll differ diff --git a/ArmaDragonflyClient_x64.so b/ArmaDragonflyClient_x64.so index 6acd99d..fd6c79e 100644 Binary files a/ArmaDragonflyClient_x64.so and b/ArmaDragonflyClient_x64.so differ diff --git a/addons/db/functions/fnc_addTask.sqf b/addons/db/functions/fnc_addTask.sqf index 12b50c0..4087992 100644 --- a/addons/db/functions/fnc_addTask.sqf +++ b/addons/db/functions/fnc_addTask.sqf @@ -39,10 +39,15 @@ params [["_taskType", "", [""]], ["_key", "", [""]], ["_keyField", "", [""]], [" private _task = [_taskType, _key, _keyField, _index, _value, _function, _call, _netId]; -diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_addTask' Added Task '%1' to Queue", _task]; +#ifdef __ARMA__DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_addTask' Added Task '%1' to Queue", _task]; +#endif GVAR(taskQueue) pushBack _task; -diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_addTask' Queue: %1", GVAR(taskQueue)]; -diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_addTask' Queue Size: %1", count GVAR(taskQueue)]; + +#ifdef __ARMA__DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_addTask' Queue: %1", GVAR(taskQueue)]; + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_addTask' Queue Size: %1", count GVAR(taskQueue)]; +#endif if !(GVAR(isProcessing)) then { [] spawn FUNC(processQueue); }; \ No newline at end of file diff --git a/addons/db/functions/fnc_fetch.sqf b/addons/db/functions/fnc_fetch.sqf index ffacf68..17496ea 100644 --- a/addons/db/functions/fnc_fetch.sqf +++ b/addons/db/functions/fnc_fetch.sqf @@ -20,13 +20,15 @@ ["uniqueID", "function", "index", "indextotal", "datachunk", "call", "netId"] */ -diag_log _this; +#ifdef __A3__DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_fetch' Input: %1", _this]; +#endif params ["_uniqueID", "_function", "_index", "_total", "_datachunk", "_call", "_netId"]; private _dataString = ""; private _index_array = []; -private _count_total = -1; +private _count_total = 0; dragonfly_db_fetch_array pushBackUnique [_uniqueID, _function, _index, _total, _datachunk, _call, _netId]; @@ -42,13 +44,17 @@ _count_total = { if (_count_total == _total) then { _index_array sort true; - for "_i" from 0 to (_total - 1) do { - _dataString = _dataString + ((_index_array select _i) select 1); - }; + { + _dataString = _dataString + (_x select 1); + } forEach _index_array; - diag_log _dataString; + #ifdef __ARMA__DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_fetch' Data String: %1", _dataString]; + #endif - [_uniqueID, _function, _call, (parseSimpleArray _dataString), _netId] call FUNC(handler); + private _callValue = (_call == "true"); + + [_uniqueID, _function, _callValue, (parseSimpleArray _dataString), _netId] call FUNC(handler); dragonfly_db_fetch_array = dragonfly_db_fetch_array select {!((_x select 0) in [_uniqueID])}; }; \ No newline at end of file diff --git a/addons/db/functions/fnc_processQueue.sqf b/addons/db/functions/fnc_processQueue.sqf index b6cfc1a..7b442b9 100644 --- a/addons/db/functions/fnc_processQueue.sqf +++ b/addons/db/functions/fnc_processQueue.sqf @@ -41,25 +41,123 @@ while { count GVAR(taskQueue) > 0} do { private _call = _task select 6; private _netId = _task select 7; - diag_log text format ["Initializing Task: %1", _task]; + #ifdef __ARMA__DEBUG__ + diag_log text format ["Initializing Task: %1", _task]; + #endif switch (_taskType) do { - case "get": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _function, _call, _netId] call FUNC(get); }; - case "set": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _value] call FUNC(set); }; - case "del": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key] call FUNC(delete); }; - case "hget": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_keyField, _function, _call, _netId] call FUNC(hashGet); }; - case "hgetid": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _keyField, _function, _call, _netId] call FUNC(hashGetId); }; - case "hgetall": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_function, _call, _netId] call FUNC(hashGetAll); }; - case "hgetallid": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _function, _call, _netId] call FUNC(hashGetAllId); }; - case "hset": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_keyField, _value] call FUNC(hashSet); }; - case "hsetbulk": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_value] call FUNC(hashSetBulk); }; - case "hsetid": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _keyField, _value] call FUNC(hashSetId); }; - case "hsetidbulk": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_value] call FUNC(hashSetIdBulk); }; - case "listadd": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _value] call FUNC(listAdd); }; - case "listidx": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _index, _function, _call, _netId] call FUNC(listGet); }; - case "listrng": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _function, _call, _netId] call FUNC(listLoad); }; - case "listrem": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _index] call FUNC(listRemove); }; - case "listset": { diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; [_key, _index, _value] call FUNC(listSet); }; + case "get": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_key, _function, _call, _netId] call FUNC(get); + }; + case "set": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_key, _value] call FUNC(set); + }; + case "del": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_key] call FUNC(delete); + }; + case "hget": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_keyField, _function, _call, _netId] call FUNC(hashGet); + }; + case "hgetid": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_key, _keyField, _function, _call, _netId] call FUNC(hashGetId); + }; + case "hgetall": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_function, _call, _netId] call FUNC(hashGetAll); + }; + case "hgetallid": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_key, _function, _call, _netId] call FUNC(hashGetAllId); + }; + case "hset": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_keyField, _value] call FUNC(hashSet); + }; + case "hsetbulk": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_value] call FUNC(hashSetBulk); + }; + case "hsetid": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_key, _keyField, _value] call FUNC(hashSetId); + }; + case "hsetidbulk": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_value] call FUNC(hashSetIdBulk); + }; + case "listadd": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_key, _value] call FUNC(listAdd); + }; + case "listidx": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_key, _index, _function, _call, _netId] call FUNC(listGet); + }; + case "listrng": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_key, _function, _call, _netId] call FUNC(listLoad); + }; + case "listrem": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_key, _index] call FUNC(listRemove); + }; + case "listset": { + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_processQueue' Processing Task '%1'", _taskType]; + #endif + + [_key, _index, _value] call FUNC(listSet); + }; }; sleep 1; diff --git a/addons/db/functions/fnc_pubSubFetch.sqf b/addons/db/functions/fnc_pubSubFetch.sqf index 7b7803b..e578723 100644 --- a/addons/db/functions/fnc_pubSubFetch.sqf +++ b/addons/db/functions/fnc_pubSubFetch.sqf @@ -46,7 +46,9 @@ if (_count_total == _total) then { _dataString = _dataString + ((_index_array select _i) select 1); }; - diag_log _dataString; + #ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_pubSubFetch' Data String: %1", _dataString]; + #endif [_uniqueID, _eventType, _eventName, (parseSimpleArray _dataString), _target] call FUNC(pubSubHandler); diff --git a/addons/db/functions/fnc_publish.sqf b/addons/db/functions/fnc_publish.sqf index 2d51696..3b848a2 100644 --- a/addons/db/functions/fnc_publish.sqf +++ b/addons/db/functions/fnc_publish.sqf @@ -45,6 +45,8 @@ private _formattedArgs = _args apply { if (_x isEqualType "") then { str _x } el private _extensionArgs = _formattedArgs joinString ","; private _result = "ArmaDragonflyClient" callExtension ["publish", [_extensionArgs]]; -diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_publish' Published message to channel '%1': '%2'", _channel, _message]; +#ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_publish' Published message to channel '%1': '%2'", _channel, _message]; +#endif true \ No newline at end of file diff --git a/addons/db/functions/fnc_subscribe.sqf b/addons/db/functions/fnc_subscribe.sqf index 231975c..a961e33 100644 --- a/addons/db/functions/fnc_subscribe.sqf +++ b/addons/db/functions/fnc_subscribe.sqf @@ -67,6 +67,8 @@ private _formattedArgs = _args apply { if (_x isEqualType "") then { str _x } el private _extensionArgs = _formattedArgs joinString ","; private _result = "ArmaDragonflyClient" callExtension ["subscribe", [_extensionArgs]]; -diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_subscribe' Subscribed to channel '%1' with event type '%2' and event name '%3'", _channel, _eventType, _eventName]; +#ifdef __ARMA_DEBUG__ + diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_subscribe' Subscribed to channel '%1' with event type '%2' and event name '%3'", _channel, _eventType, _eventName]; +#endif true \ No newline at end of file diff --git a/addons/db/functions/fnc_test.sqf b/addons/db/functions/fnc_test.sqf index ffcfe63..c24579a 100644 --- a/addons/db/functions/fnc_test.sqf +++ b/addons/db/functions/fnc_test.sqf @@ -31,4 +31,5 @@ _res = _this; dragonfly_db_test = _res; -hint format ["%1", _res]; \ No newline at end of file +hint format ["%1", _res]; +diag_log text format ["ArmaDragonflyClient: 'dragonfly_db_fnc_test' Result: %1", _res]; \ No newline at end of file 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 index 6acd99d..fd6c79e 100644 Binary files a/extension/bin/Release/net8.0/linux-x64/publish/ArmaDragonflyClient_x64.so 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 index 2af4bd2..640ee2d 100644 Binary files a/extension/bin/Release/net8.0/win-x64/publish/ArmaDragonflyClient_x64.dll and b/extension/bin/Release/net8.0/win-x64/publish/ArmaDragonflyClient_x64.dll differ diff --git a/extension/src/Main.cs b/extension/src/Main.cs index 5bb1607..2051712 100644 --- a/extension/src/Main.cs +++ b/extension/src/Main.cs @@ -18,11 +18,11 @@ namespace ArmaDragonflyClient public class Main { private const string ADC_VERSION = "1.0.0"; - public const int ADC_BUFFERSIZE = 1024; + public const int ADC_BUFFERSIZE = 10240; 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"; - public static string ADC_LOGFOLDER {get; private set; } = "\\@dragonfly\\logs"; + public static string ADC_LOGFOLDER {get; private set; } = $"{Path.DirectorySeparatorChar}@dragonfly{Path.DirectorySeparatorChar}logs"; public static bool ADC_DEBUG {get; private set; } = false; public static bool ADC_INITCHECK {get; private set; } = false; public static string STEAMID {get; private set; } = ""; @@ -50,12 +50,12 @@ namespace ArmaDragonflyClient } if (str == "") - str = "@dragonfly\\config.xml"; + str = $"{Path.DirectorySeparatorChar}@dragonfly{Path.DirectorySeparatorChar}config.xml"; - if (File.Exists(Environment.CurrentDirectory + "\\" + str)) + if (File.Exists(Environment.CurrentDirectory + $"{Path.DirectorySeparatorChar}{str}")) { List strList = []; - List list = XElement.Load(Environment.CurrentDirectory + "\\" + str).Elements().Select((Func)(eintrag => (string)eintrag)).ToList(); + List list = [.. XElement.Load(Environment.CurrentDirectory + $"{Path.DirectorySeparatorChar}{str}").Elements().Select(eintrag => (string)eintrag)]; ADC_HOST = list[0]; ADC_PORT = Convert.ToInt32(list[1]); ADC_PASSWORD = list[2]; @@ -64,7 +64,7 @@ namespace ArmaDragonflyClient if (bool.TryParse(list[4], out bool res2)) ADC_DEBUG = res2; - Log(string.Format("Config file found! Context Mode: {3}! Debug Mode: {4}! Changed Server Settings to: {0}:{1}:{2}!", (object)ADC_HOST, (object)ADC_PORT, (object)ADC_PASSWORD, (object)ADC_CONTEXTLOG, (object)ADC_DEBUG), "action"); + Log($"Config file found! Context Mode: {ADC_CONTEXTLOG}! Debug Mode: {ADC_DEBUG}! Changed Server Settings to: {ADC_HOST}:{ADC_PORT}:{ADC_PASSWORD}!", "action"); } else { @@ -341,12 +341,18 @@ namespace ArmaDragonflyClient Task.Run(async () => { string _uniqueID = $"{_id}_get"; - if (argsCnt == 2) - await DragonflyDB.DragonflyGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID); - if (argsCnt == 3) - await DragonflyDB.DragonflyGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"')); - if (argsCnt == 4) - await DragonflyDB.DragonflyGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"'), argsArr[3].Trim('"')); + switch (argsCnt) + { + case 2: + await DragonflyDB.DragonflyGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID); + break; + case 3: + await DragonflyDB.DragonflyGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"')); + break; + case 4: + await DragonflyDB.DragonflyGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"'), argsArr[3].Trim('"')); + break; + } }); } @@ -390,12 +396,18 @@ namespace ArmaDragonflyClient Task.Run(async () => { string _uniqueID = $"{_id}_listidx"; - if (argsCnt == 3) - await DragonflyDB.DragonflyListIndexAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID); - if (argsCnt == 4) - await DragonflyDB.DragonflyListIndexAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID, argsArr[3].Trim('"')); - if (argsCnt == 5) - await DragonflyDB.DragonflyListIndexAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID, argsArr[3].Trim('"'), argsArr[4].Trim('"')); + switch (argsCnt) + { + case 3: + await DragonflyDB.DragonflyListIndexAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID); + break; + case 4: + await DragonflyDB.DragonflyListIndexAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID, argsArr[3].Trim('"')); + break; + case 5: + await DragonflyDB.DragonflyListIndexAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID, argsArr[3].Trim('"'), argsArr[4].Trim('"')); + break; + } }); } @@ -413,12 +425,18 @@ namespace ArmaDragonflyClient Task.Run(async () => { string _uniqueID = $"{_id}_listrng"; - if (argsCnt == 4) - await DragonflyDB.DragonflyListRangeAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), argsArr[3].Trim('"'), _uniqueID); - if (argsCnt == 5) - await DragonflyDB.DragonflyListRangeAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), argsArr[3].Trim('"'), _uniqueID, argsArr[4].Trim('"')); - if (argsCnt == 6) - await DragonflyDB.DragonflyListRangeAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), argsArr[3].Trim('"'), _uniqueID, argsArr[4].Trim('"'), argsArr[5].Trim('"')); + switch (argsCnt) + { + case 4: + await DragonflyDB.DragonflyListRangeAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), argsArr[3].Trim('"'), _uniqueID); + break; + case 5: + await DragonflyDB.DragonflyListRangeAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), argsArr[3].Trim('"'), _uniqueID, argsArr[4].Trim('"')); + break; + case 6: + await DragonflyDB.DragonflyListRangeAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), argsArr[3].Trim('"'), _uniqueID, argsArr[4].Trim('"'), argsArr[5].Trim('"')); + break; + } }); } @@ -442,16 +460,17 @@ namespace ArmaDragonflyClient { Task.Run(async () => { - if (argsCnt > 2) + switch (argsCnt) { - for (var i = 0; i < argsCnt; i += 2) - { - await DragonflyDB.DragonflyHashSetAsync(STEAMID, argsArr[i].Trim('"'), argsArr[i + 1]); - } - } - else - { - await DragonflyDB.DragonflyHashSetAsync(STEAMID, argsArr[0].Trim('"'), argsArr[1]); + case > 2: + for (var i = 0; i < argsCnt; i += 2) + { + await DragonflyDB.DragonflyHashSetAsync(STEAMID, argsArr[i].Trim('"'), argsArr[i + 1]); + } + break; + default: + await DragonflyDB.DragonflyHashSetAsync(STEAMID, argsArr[0].Trim('"'), argsArr[1]); + break; } }); } @@ -459,16 +478,17 @@ namespace ArmaDragonflyClient private static void HandleHSetIdOperation(List argsArr, int argsCnt) { Task.Run(async () => { - if (argsCnt > 4) + switch (argsCnt) { - for (var i = 1; i < argsCnt; i += 2) - { - await DragonflyDB.DragonflyHashSetAsync(argsArr[0].Trim('"'), argsArr[i].Trim('"'), argsArr[i + 1]); - } - } - else - { - await DragonflyDB.DragonflyHashSetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2]); + case > 4: + for (var i = 1; i < argsCnt; i += 2) + { + await DragonflyDB.DragonflyHashSetAsync(argsArr[0].Trim('"'), argsArr[i].Trim('"'), argsArr[i + 1]); + } + break; + default: + await DragonflyDB.DragonflyHashSetAsync(argsArr[0].Trim('"'), argsArr[1], argsArr[2]); + break; } }); } @@ -478,12 +498,18 @@ namespace ArmaDragonflyClient Task.Run(async () => { string _uniqueID = $"{_id}_hget"; - if (argsCnt == 2) - await DragonflyDB.DragonflyHashGetAsync(STEAMID, argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID); - if (argsCnt == 3) - await DragonflyDB.DragonflyHashGetAsync(STEAMID, argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"')); - if (argsCnt == 4) - await DragonflyDB.DragonflyHashGetAsync(STEAMID, argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"'), argsArr[3].Trim('"')); + switch (argsCnt) + { + case 2: + await DragonflyDB.DragonflyHashGetAsync(STEAMID, argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID); + break; + case 3: + await DragonflyDB.DragonflyHashGetAsync(STEAMID, argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"')); + break; + case 4: + await DragonflyDB.DragonflyHashGetAsync(STEAMID, argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"'), argsArr[3].Trim('"')); + break; + } }); } @@ -492,12 +518,18 @@ namespace ArmaDragonflyClient Task.Run(async () => { string _uniqueID = $"{_id}_hgetid"; - if (argsCnt == 3) - await DragonflyDB.DragonflyHashGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID); - if (argsCnt == 4) - await DragonflyDB.DragonflyHashGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID, argsArr[3].Trim('"')); - if (argsCnt == 5) - await DragonflyDB.DragonflyHashGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID, argsArr[3].Trim('"'), argsArr[4].Trim('"')); + switch (argsCnt) + { + case 3: + await DragonflyDB.DragonflyHashGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID); + break; + case 4: + await DragonflyDB.DragonflyHashGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID, argsArr[3].Trim('"')); + break; + case 5: + await DragonflyDB.DragonflyHashGetAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID, argsArr[3].Trim('"'), argsArr[4].Trim('"')); + break; + } }); } @@ -506,12 +538,18 @@ namespace ArmaDragonflyClient Task.Run(async () => { string _uniqueID = $"{_id}_hgetall"; - if (argsCnt == 1) - await DragonflyDB.DragonflyHashGetAllAsync(STEAMID, argsArr[0].Trim('"'), _uniqueID); - if (argsCnt == 2) - await DragonflyDB.DragonflyHashGetAllAsync(STEAMID, argsArr[0].Trim('"'), _uniqueID, argsArr[1].Trim('"')); - if (argsCnt == 3) - await DragonflyDB.DragonflyHashGetAllAsync(STEAMID, argsArr[0].Trim('"'), _uniqueID, argsArr[1].Trim('"'), argsArr[2].Trim('"')); + switch (argsCnt) + { + case 1: + await DragonflyDB.DragonflyHashGetAllAsync(STEAMID, argsArr[0].Trim('"'), _uniqueID); + break; + case 2: + await DragonflyDB.DragonflyHashGetAllAsync(STEAMID, argsArr[0].Trim('"'), _uniqueID, argsArr[1].Trim('"')); + break; + case 3: + await DragonflyDB.DragonflyHashGetAllAsync(STEAMID, argsArr[0].Trim('"'), _uniqueID, argsArr[1].Trim('"'), argsArr[2].Trim('"')); + break; + } }); } @@ -520,12 +558,18 @@ namespace ArmaDragonflyClient Task.Run(async () => { string _uniqueID = $"{_id}_hgetallid"; - if (argsCnt == 2) - await DragonflyDB.DragonflyHashGetAllAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID); - if (argsCnt == 3) - await DragonflyDB.DragonflyHashGetAllAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"')); - if (argsCnt == 4) - await DragonflyDB.DragonflyHashGetAllAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"'), argsArr[3].Trim('"')); + switch (argsCnt) + { + case 2: + await DragonflyDB.DragonflyHashGetAllAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID); + break; + case 3: + await DragonflyDB.DragonflyHashGetAllAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"')); + break; + case 4: + await DragonflyDB.DragonflyHashGetAllAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), _uniqueID, argsArr[2].Trim('"'), argsArr[3].Trim('"')); + break; + } }); } @@ -594,10 +638,15 @@ namespace ArmaDragonflyClient Task.Run(async () => { string _uniqueID = $"{_id}_subscribe"; - if (argsCnt == 3) - await DragonflyDB.DragonflySubscribeAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID); - if (argsCnt == 4) - await DragonflyDB.DragonflySubscribeAsync(argsArr[0].Trim('"'), argsArr[1].Trim('"'), argsArr[2].Trim('"'), _uniqueID, argsArr[3].Trim('"')); + 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; + } }); } } diff --git a/extension/src/Utils.cs b/extension/src/Utils.cs index 8e45400..386ce2a 100644 --- a/extension/src/Utils.cs +++ b/extension/src/Utils.cs @@ -52,22 +52,9 @@ namespace ArmaDragonflyClient data = BuildArray(data); Main.Log($"{data}", "debug"); - string dataAsString = $"[\"{uniqueId}\",\"{function}\",{call},{data},\"{entity}\"]"; + string dataAsString = $"[\"{uniqueId}\",\"{function}\",{call.ToString().ToLower()},{data},\"{entity}\"]"; Main.Log($"{dataAsString}", "debug"); Main.Callback("ArmaDragonflyClient", "dragonfly_db_fnc_handler", dataAsString); - - // if (entity == null) - // { - // string dataAsString = $"[\"{uniqueId}\",\"{function}\",{call},{data}]"; - // Main.Log($"{dataAsString}", "debug"); - // Main.Callback("ArmaDragonflyClient", "dragonfly_db_fnc_handler", dataAsString); - // } - // else - // { - // string dataAsString = $"[\"{uniqueId}\",\"{function}\",{call},{data},\"{entity}\"]"; - // Main.Log($"{dataAsString}", "debug"); - // Main.Callback("ArmaDragonflyClient", "dragonfly_db_fnc_handler", dataAsString); - // }; } else { @@ -77,9 +64,11 @@ namespace ArmaDragonflyClient var chunks = SplitIntoChunks(data, bufferSize); int totalChunks = chunks.Count; - foreach (string chunk in chunks) + for (int i = 0; i < chunks.Count; i++) { - string chunkAsString = $"[{uniqueId},{function},{chunks.IndexOf(chunk)},{totalChunks},\"{chunk}\",{call},\"{entity}\"]"; + string escapedChunk = chunks[i].Replace("\"", "\"\""); + string callString = call ? "true" : "false"; + string chunkAsString = $"[\"{uniqueId}\",\"{function}\",{i+1},{totalChunks},\"{escapedChunk}\",\"{callString}\",\"{entity}\"]"; Main.Callback("ArmaDragonflyClient", "dragonfly_db_fnc_fetch", chunkAsString); } } @@ -105,9 +94,10 @@ namespace ArmaDragonflyClient var chunks = SplitIntoChunks(data, bufferSize); int totalChunks = chunks.Count; - foreach (string chunk in chunks) + for (int i = 0; i < chunks.Count; i++) { - string chunkAsString = $"[{uniqueId},{eventType},{eventName},{chunks.IndexOf(chunk)},{totalChunks},\"{chunk}\",\"{target}\"]"; + string escapedChunk = chunks[i].Replace("\"", "\"\""); + string chunkAsString = $"[\"{uniqueId}\",\"{eventType}\",\"{eventName}\",{i+1},{totalChunks},\"{escapedChunk}\",\"{target}\"]"; Main.Callback("ArmaDragonflyClient", "dragonfly_db_fnc_pubSubFetch", chunkAsString); } }