added get_uid and get_auth_token functions

This commit is contained in:
Valmo Trindade
2024-08-19 03:38:27 -03:00
parent d514983806
commit 558a5fc4f7
5 changed files with 71 additions and 451 deletions

View File

@@ -1,14 +1,15 @@
_atak_server_instance_username = missionNamespace getVariable "_atak_server_instance_username";
_atak_server_instance_password = missionNamespace getVariable "_atak_server_instance_password";
private _atak_server_instance = missionNamespace getVariable "_atak_server_instance";
private _atak_server_instance_username = missionNamespace getVariable "_atak_server_instance_username";
private _atak_server_instance_password = missionNamespace getVariable "_atak_server_instance_password";
_authentication = [_atak_server_instance_username, _atak_server_instance_password];
private _authentication = [_atak_server_instance, _atak_server_instance_username, _atak_server_instance_password];
_atak_server_instance_token = "armatak" callExtension ["get_auth_token", _authentication];
_atak_server_instance_token = ("armatak" callExtension ["get_auth_token", _authentication]) select 0;
if (_atak_server_instance_token != "") then {
missionName setVariable ["_atak_server_instance_token", _atak_server_instance_token];
if ((_atak_server_instance_token != "") and !(["error", _atak_server_instance_token, false] call BIS_fnc_inString)) then {
missionNamespace setVariable ["_atak_server_instance_token", _atak_server_instance_token];
private _warning = format ["<t color='#FF0000'>ARMATAK</t><br/> %1", "Authorized"];
private _warning = format ["<t color='#2B7319'>ARMATAK</t><br/> %1", "Authorized"];
[[_warning, 1.5]] call CBA_fnc_notify;
} else {
private _warning = format ["<t color='#FF0000'>ARMATAK</t><br/> %1", "Failed to get Auth Token"];

View File

@@ -8,40 +8,17 @@ if (_activated) exitWith {
private _warning = format ["<t color='#FF8021'>ARMATAK</t><br/> %1", "Connecting..."];
[[_warning, 1.5]] call CBA_fnc_notify;
_atak_fts_address = _logic getVariable "armatak_module_fts_api_instance_address";
_atak_fts_protocol = _logic getVariable "armatak_module_fts_api_instance_protocol";
_atak_fts_port = _logic getVariable "armatak_module_fts_api_instance_port";
_atak_ots_address = _logic getVariable "armatak_module_ots_api_instance_address";
_atak_ots_protocol = _logic getVariable "armatak_module_ots_api_instance_protocol";
_atak_ots_port = _logic getVariable "armatak_module_ots_api_instance_port";
_atak_fts_fulladdress = _atak_fts_protocol + ":" + "/" + "/" + _atak_fts_address + ":" + (str _atak_fts_port);
_atak_fts_bearer_token = _logic getVariable "armatak_module_fts_api_instance_token";
_atak_ots_fulladdress = _atak_ots_protocol + ":" + "/" + "/" + _atak_ots_address + ":" + (str _atak_ots_port);
_atak_ots_api_username = _logic getVariable "armatak_module_ots_api_instance_username";
_atak_ots_api_password = _logic getVariable "armatak_module_ots_api_instance_password";
missionNamespace setVariable ["_atak_server_instance", _atak_fts_fulladdress];
missionNamespace setVariable ["_atak_server_instance_token", _atak_fts_bearer_token];
missionNamespace setVariable ["_atak_server_instance", _atak_ots_fulladdress];
missionNamespace setVariable ["_atak_server_instance_username", _atak_ots_api_username];
missionNamespace setVariable ["_atak_server_instance_password", _atak_ots_api_password];
if (isMultiplayer) then {
{
[{
_uid = _x getVariable "_atak_uid";
if (_uid == "") then {
[_x] call armatak_fnc_postGeoObject;
} else {
[_x] call armatak_fnc_putGeoObject;
};
}, 1, []] call CBA_fnc_addPerFrameHandler;
} forEach playableUnits;
} else {
[{
_uid = player getVariable "_atak_uid";
if (_uid == "") then {
[player] call armatak_fnc_postGeoObject;
} else {
[player] call armatak_fnc_putGeoObject;
};
}, 1, []] call CBA_fnc_addPerFrameHandler;
};
private _warning = format ["<t color='#FF8021'>ARMATAK</t><br/> %1", "Connected!"];
[[_warning, 1.5]] call CBA_fnc_notify;
};
_atak_server_instance_token = call armatak_fnc_extract_auth_token;
};