From 60f04bc4e881a496f3ce8cb9b39c561ebb2223a9 Mon Sep 17 00:00:00 2001 From: Valmo Trindade Date: Tue, 17 Jun 2025 03:57:23 -0300 Subject: [PATCH] added start and stop functions for the UDP Socket --- addons/client/XEH_PREP.hpp | 2 ++ .../client/functions/fnc_startUDPSocket.sqf | 31 +++++++++++++++++++ addons/client/functions/fnc_stopUDPSocket.sqf | 0 3 files changed, 33 insertions(+) create mode 100644 addons/client/functions/fnc_startUDPSocket.sqf create mode 100644 addons/client/functions/fnc_stopUDPSocket.sqf diff --git a/addons/client/XEH_PREP.hpp b/addons/client/XEH_PREP.hpp index 6888b1d..c38b1f0 100644 --- a/addons/client/XEH_PREP.hpp +++ b/addons/client/XEH_PREP.hpp @@ -1,2 +1,4 @@ PREP(convertClientLocation); PREP(extractClientPosition); +PREP(startUDPSocket); +PREP(stopUDPSocket); \ No newline at end of file diff --git a/addons/client/functions/fnc_startUDPSocket.sqf b/addons/client/functions/fnc_startUDPSocket.sqf new file mode 100644 index 0000000..da8ca0f --- /dev/null +++ b/addons/client/functions/fnc_startUDPSocket.sqf @@ -0,0 +1,31 @@ +#include "..\script_component.hpp" + +params ["_logic"]; + +_socket_is_running = player getVariable [QGVAR(eudConnected), false]; + +if (_socket_is_running) exitWith { + ["Socket is already running", "error", "UDP Socket"] call EFUNC(main,notify); + closeDialog 1; +}; + +disableSerialization; + +_udp_socket_instance_address = ctrlText 16961; +_udp_socket_instance_port = ctrlText 16962; + +_udp_socket_fulladdress = ((_udp_socket_instance_address) + ":" + (_udp_socket_instance_port)); + +player setVariable [QGVAR(udp_socket_address), _udp_socket_fulladdress]; +player setVariable [QGVAR(eudConnected), true]; + +"armatak" callExtension ["udp_socket:start", [_udp_socket_fulladdress]]; + +[{ + if (player getVariable [QGVAR(eudConnected), false]) then { + "armatak" callExtension ["udp_socket:send_gps_cot", [player call FUNC(extractClientPosition)]]; + }; +}, 2, []] call CBA_fnc_addPerFrameHandler; + +deleteVehicle _logic; +closeDialog 1; \ No newline at end of file diff --git a/addons/client/functions/fnc_stopUDPSocket.sqf b/addons/client/functions/fnc_stopUDPSocket.sqf new file mode 100644 index 0000000..e69de29