mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 14:03:29 +00:00
refactored armatak core module to initiate the TCP Client with the provided address
This commit is contained in:
@@ -27,7 +27,7 @@ class CfgVehicles {
|
||||
};
|
||||
class armatak_module_core: Module_F {
|
||||
scope = 2;
|
||||
displayname = "ARMATAK Core";
|
||||
displayname = "ARMATAK CoT Router";
|
||||
icon = "\a3\Modules_F_Curator\Data\iconRadio_ca.paa";
|
||||
category = "armatak_module_category";
|
||||
function = "armatak_fnc_init";
|
||||
@@ -52,63 +52,25 @@ class CfgVehicles {
|
||||
class Units: Units {
|
||||
property = "armatak_module_attached_units";
|
||||
};
|
||||
class armatak_module_api_instance: Combo {
|
||||
property = "armatak_module_api_instance";
|
||||
displayname = "TAK API Instance";
|
||||
tooltip = "Used TAK Server Instance";
|
||||
typeName = "STRING";
|
||||
defaultValue = "ots";
|
||||
|
||||
class Values {
|
||||
class ots { name = "Open TAK Server"; value = "ots"; default = 1; };
|
||||
class fts { name = "Free TAK Server"; value = "fts"; };
|
||||
};
|
||||
};
|
||||
class armatak_module_api_instance_protocol: Combo {
|
||||
property = "armatak_module_api_instance_protocol";
|
||||
displayname = "OTS Protocol";
|
||||
tooltip = "OpenTAKServer instance protocol";
|
||||
typeName = "STRING";
|
||||
defaultValue = "http";
|
||||
|
||||
class Values {
|
||||
class http { name = "HTTP"; value = "http"; default = 1; };
|
||||
class https { name = "HTTPS"; value = "https"; };
|
||||
};
|
||||
};
|
||||
class armatak_module_api_instance_address: Edit {
|
||||
property = "armatak_module_api_instance_address";
|
||||
displayname = "OTS Address";
|
||||
tooltip = "OpenTAKServer Instance Address";
|
||||
class armatak_module_tak_server_instance_address: Edit {
|
||||
property = "armatak_module_tak_server_instance_address";
|
||||
displayname = "TAK Server Address";
|
||||
tooltip = "TAK Server Instance Address";
|
||||
typeName = "STRING";
|
||||
defaultValue = "localhost";
|
||||
};
|
||||
class armatak_module_api_instance_port: Edit {
|
||||
property = "armatak_module_api_instance_port";
|
||||
displayname = "OTS Port";
|
||||
tooltip = "OpenTAKServer Instance Port";
|
||||
class armatak_module_tak_server_instance_port: Edit {
|
||||
property = "armatak_module_tak_server_instance_port";
|
||||
displayname = "TAK Server TCP Port";
|
||||
tooltip = "TAK Server instance Port for TCP connection";
|
||||
typeName = "NUMBER";
|
||||
defaultValue = "8080";
|
||||
};
|
||||
class armatak_module_api_instance_username: Edit {
|
||||
property = "armatak_module_api_instance_username";
|
||||
displayname = "API Username";
|
||||
tooltip = "API Username for authorization";
|
||||
typeName = "STRING";
|
||||
defaultValue = "administrator";
|
||||
};
|
||||
class armatak_module_api_instance_password: Edit {
|
||||
property = "armatak_module_api_instance_password";
|
||||
displayname = "API Password";
|
||||
tooltip = "API Password for authorization";
|
||||
typeName = "STRING";
|
||||
defaultValue = "password";
|
||||
};
|
||||
class ModuleDescription: ModuleDescription {};
|
||||
};
|
||||
|
||||
class ModuleDescription: ModuleDescription {
|
||||
description = "Generate the initial ARMATAK configuration, syncronizing all players to the OTS instance";
|
||||
description = "Generate the initial ARMATAK configuration, syncronizing all players to the TAK server instance";
|
||||
sync[] = {"LocationArea_F"};
|
||||
|
||||
class LocationArea_F {
|
||||
|
||||
@@ -5,56 +5,39 @@ params [
|
||||
];
|
||||
|
||||
if (isServer) exitWith {
|
||||
_warning = format ["<t color='#FF8021'>ARMATAK</t><br/> %1", "Connecting to API Provider..."];
|
||||
_warning = format ["<t color='#FF8021'>ARMATAK</t><br/> %1", "Connecting to TAK Server TCP Socket..."];
|
||||
[[_warning, 1.5]] call CBA_fnc_notify;
|
||||
|
||||
_atak_instance = _logic getVariable "armatak_module_api_instance";
|
||||
_atak_instance_protocol = _logic getVariable "armatak_module_api_instance_protocol";
|
||||
_atak_instance_address = _logic getVariable "armatak_module_api_instance_address";
|
||||
_atak_instance_port = _logic getVariable "armatak_module_api_instance_port";
|
||||
_tak_server_instance_address = _logic getVariable "armatak_module_tak_server_instance_address";
|
||||
_tak_server_instance_port = _logic getVariable "armatak_module_tak_server_instance_port";
|
||||
|
||||
_atak_fulladdress = _atak_instance_protocol + ":" + "/" + "/" + _atak_instance_address + ":" + (str _atak_instance_port);
|
||||
_atak_api_username = _logic getVariable "armatak_module_api_instance_username";
|
||||
_atak_api_password = _logic getVariable "armatak_module_api_instance_password";
|
||||
_tak_server_fulladdress = _tak_server_instance_address + ":" + (str _tak_server_instance_port);
|
||||
|
||||
if (_atak_instance == "ots") then {
|
||||
missionNamespace setVariable ["_atak_server_instance", _atak_fulladdress];
|
||||
missionNamespace setVariable ["_atak_server_instance_username", _atak_api_username];
|
||||
missionNamespace setVariable ["_atak_server_instance_password", _atak_api_password];
|
||||
missionNamespace setVariable ["_atak_server_instance", _tak_server_fulladdress];
|
||||
missionNamespace setVariable ["_group_colors", ["White", "Yellow", "Orange", "Magenta", "Red", "Maroon", "Purple", "DarkBlue", "Blue", "Cyan", "Teal", "Green", "DarkGreen", "Brown"]];
|
||||
|
||||
_atak_server_instance_token = call armatak_fnc_ots_extract_auth_token;
|
||||
|
||||
if ((_atak_server_instance_token == "") and !(["ERROR", _atak_server_instance_token, false] call BIS_fnc_inString)) then {
|
||||
private _warning = format ["<t color='#FF0000'>ARMATAK</t><br/> %1", "Connection Failed"];
|
||||
[[_warning, 2]] call CBA_fnc_notify;
|
||||
} else {
|
||||
private _warning = format ["<t color='#2B7319'>ARMATAK</t><br/> %1", "Connected"];
|
||||
[[_warning, 2]] call CBA_fnc_notify;
|
||||
};
|
||||
|
||||
_syncUnits = synchronizedObjects _logic;
|
||||
|
||||
missionNamespace setVariable ["_armatak_marked_units", _syncUnits];
|
||||
"armatak" callExtension ["cot_router:start", [_tak_server_fulladdress]];
|
||||
|
||||
/*
|
||||
[{
|
||||
[{
|
||||
[{
|
||||
_syncedUnits = missionNamespace getVariable "_armatak_marked_units";
|
||||
_markers = [];
|
||||
_syncedUnits = missionNamespace getVariable "_armatak_marked_units";
|
||||
_markers = [];
|
||||
|
||||
{
|
||||
if (unitIsUAV _x) then {
|
||||
_marker = _x call armatak_fnc_extract_drone_info;
|
||||
_markers append [_marker];
|
||||
} else {
|
||||
_marker = _x call armatak_fnc_extract_info;
|
||||
_markers append [_marker];
|
||||
};
|
||||
} forEach _syncedUnits;
|
||||
{
|
||||
if (unitIsUAV _x) then {
|
||||
_marker = _x call armatak_fnc_extract_drone_info;
|
||||
_markers append [_marker];
|
||||
} else {
|
||||
_marker = _x call armatak_fnc_extract_info;
|
||||
_markers append [_marker];
|
||||
};
|
||||
} forEach _syncedUnits;
|
||||
|
||||
_request = "armatak" callExtension ["ots_api:post", [_markers]];
|
||||
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
}, [], 1] call CBA_fnc_waitAndExecute;
|
||||
};
|
||||
_request = "armatak" callExtension ["ots_api:post", [_markers]];
|
||||
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
}, [], 1] call CBA_fnc_waitAndExecute;
|
||||
*/
|
||||
};
|
||||
|
||||
true;
|
||||
|
||||
Reference in New Issue
Block a user