mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 15:33:29 +00:00
added start websocket function root of the extension to make universally started when the extension is called
This commit is contained in:
@@ -6,8 +6,8 @@ prefix = "armatak"
|
|||||||
[version]
|
[version]
|
||||||
build = 0
|
build = 0
|
||||||
major = 0
|
major = 0
|
||||||
minor = 7
|
minor = 8
|
||||||
patch = 5
|
patch = 1
|
||||||
|
|
||||||
git_hash = 0
|
git_hash = 0
|
||||||
|
|
||||||
|
|||||||
2
Cargo.lock
generated
2
Cargo.lock
generated
@@ -83,7 +83,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "armatak"
|
name = "armatak"
|
||||||
version = "0.7.5"
|
version = "0.8.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"arma-rs",
|
"arma-rs",
|
||||||
"futures",
|
"futures",
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "armatak"
|
name = "armatak"
|
||||||
version = "0.7.5"
|
version = "0.8.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
@@ -57,4 +57,4 @@ if (isServer && _activated) exitWith {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
true;
|
true;
|
||||||
|
|||||||
@@ -1,39 +1,18 @@
|
|||||||
if (!hasInterface) exitWith {};
|
if (!hasInterface) exitWith {};
|
||||||
|
|
||||||
_initializedServer = "armatak" callExtension ["websocket:start",[]] select 0;
|
|
||||||
_local_address = "armatak" callExtension ["local_ip", []] select 0;
|
_local_address = "armatak" callExtension ["local_ip", []] select 0;
|
||||||
|
|
||||||
player setVariable ["initializedSocket", _initializedServer];
|
|
||||||
player setVariable ["localAddress", _local_address];
|
player setVariable ["localAddress", _local_address];
|
||||||
|
|
||||||
player addEventHandler ["Killed", {
|
|
||||||
"armatak" callExtension ["websocket:stop", []];
|
|
||||||
}];
|
|
||||||
|
|
||||||
player addEventHandler ["Deleted", {
|
|
||||||
"armatak" callExtension ["websocket:stop", []];
|
|
||||||
}];
|
|
||||||
|
|
||||||
player addEventHandler ["Respawn", {
|
player addEventHandler ["Respawn", {
|
||||||
params["_unit", "_corpse"];
|
params["_unit", "_corpse"];
|
||||||
|
[{
|
||||||
_unit spawn {
|
if (alive _this) then {
|
||||||
"armatak" callExtension ["websocket:start", []];
|
"armatak" callExtension ["websocket:location", [player call armatak_fnc_extract_position]];
|
||||||
|
};
|
||||||
[{
|
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||||
if (alive _this) then {
|
|
||||||
"armatak" callExtension ["websocket:location",[player call armatak_fnc_extract_position]];
|
|
||||||
};
|
|
||||||
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
|
||||||
};
|
|
||||||
}];
|
}];
|
||||||
|
|
||||||
addMissionEventHandler ["OnUserDisconnected", {
|
[{
|
||||||
"armatak" callExtension ["websocket:stop", []];
|
"armatak" callExtension ["websocket:location", [player call armatak_fnc_extract_position]];
|
||||||
}];
|
|
||||||
|
|
||||||
onPlayerDisconnected "'armatak' callExtension ['websocket:stop',[]];";
|
|
||||||
|
|
||||||
[{
|
|
||||||
"armatak" callExtension ["websocket:location",[player call armatak_fnc_extract_position]];
|
|
||||||
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use arma_rs::{arma, Extension, Group};
|
use arma_rs::{arma, Extension, Group};
|
||||||
mod commands;
|
|
||||||
mod structs;
|
mod structs;
|
||||||
mod tests;
|
mod tests;
|
||||||
mod websocket;
|
mod websocket;
|
||||||
@@ -30,10 +29,10 @@ pub fn init() -> Extension {
|
|||||||
|
|
||||||
log4rs::init_config(config).unwrap();
|
log4rs::init_config(config).unwrap();
|
||||||
|
|
||||||
|
websocket::start();
|
||||||
|
|
||||||
Extension::build()
|
Extension::build()
|
||||||
.group("websocket", Group::new()
|
.group("websocket", Group::new()
|
||||||
.command("start", websocket::start)
|
|
||||||
.command("stop", websocket::stop)
|
|
||||||
.command("message", websocket::message)
|
.command("message", websocket::message)
|
||||||
.command("location", websocket::location)
|
.command("location", websocket::location)
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -112,13 +112,3 @@ pub fn location(payload: LocationPayload) -> &'static str {
|
|||||||
}
|
}
|
||||||
"sending location to all WebSocket clients"
|
"sending location to all WebSocket clients"
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn stop() -> &'static str {
|
|
||||||
if let Some(ref server) = *WEBSOCKET_SERVER.lock().unwrap() {
|
|
||||||
server.stop();
|
|
||||||
} else {
|
|
||||||
info!("WebSocket server is not running.");
|
|
||||||
}
|
|
||||||
|
|
||||||
"Stopping WebSocket server"
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user