Skip to content
Snippets Groups Projects
Commit d02320b1 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Webservice ping for keepalive and latency

parent ea007e23
No related branches found
No related tags found
No related merge requests found
Pipeline #29190 failed
......@@ -55,9 +55,9 @@ webserver-deploy:
.build-windows: &build-windows
- 'call vcvars64.bat'
- if not exist "../ftl_build" mkdir "../ftl_build"
- cd ../ftl_build
- cmake %CMAKE_ARGS% %CMAKE_ARGS_WINDOWS% -DREALSENSE_DIR="C:/Program Files (x86)/Intel RealSense SDK 2.0" -DOPENVR_DIR="C:/Program Files (x86)/OpenVRSDK" -DOPUS_DIR="C:/Program Files (x86)/Opus" ../ftl
- mkdir ./build
- cd ./build
- cmake %CMAKE_ARGS% %CMAKE_ARGS_WINDOWS% -DREALSENSE_DIR="C:/Program Files (x86)/Intel RealSense SDK 2.0" -DOPENVR_DIR="C:/Program Files (x86)/OpenVRSDK" -DOPUS_DIR="C:/Program Files (x86)/Opus" ..
- devenv ftl.utu.fi.sln /build Release
- rmdir /q /s "%DEPLOY_DIR%/%CI_COMMIT_REF_SLUG%"
- mkdir "%DEPLOY_DIR%/%CI_COMMIT_REF_SLUG%"
......
......@@ -40,6 +40,18 @@ let peer_data = [];
let cfg_to_peer = {};
setInterval(() => {
for (x in peer_by_id) {
let p = peer_by_id[x];
let start = (new Date()).getMilliseconds();
p.rpc("__ping__", (ts) => {
let end = (new Date()).getMilliseconds();
p.latency = (end-start) / 2;
console.log("Ping: ", p.latency, ts);
});
}
}, 20000);
/**
* A client stream request object. Each source maintains a list of clients who
* are wanting frames from that source. Clients can only request N frames at a
......@@ -143,7 +155,8 @@ RGBDStream.prototype.pushFrames = function(latency, spacket, packet) {
//console.log("Frame = ", packet[0], packet[1]);
for (let i=0; i < this.clients.length; i++) {
this.clients[i].push(this.base_uri, latency, spacket, packet);
let l = latency+this.peer.latency+this.clients[i].peer.latency;
this.clients[i].push(this.base_uri, Math.ceil(l), spacket, packet);
}
/*let i=0;
......@@ -346,6 +359,8 @@ app.ws('/', (ws, req) => {
for (let c in cfg_to_peer) {
if (cfg_to_peer[c] === p) delete cfg_to_peer[c];
}
// FIXME: Clear peer_data
});
p.bind("new_peer", (id) => {
......
......@@ -35,6 +35,8 @@ function Peer(ws) {
this.callbacks = {};
this.cbid = 0;
this.latency = 0;
this.uri = "unknown";
this.name = "unknown";
this.master = false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment