From 89cd165345c7381de64d6710acb2b0a1ff34bb12 Mon Sep 17 00:00:00 2001 From: Nicolas Pope <nwpope@utu.fi> Date: Thu, 26 Sep 2019 10:51:05 +0300 Subject: [PATCH] Fixed web service rpc parameters --- web-service/src/index.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/web-service/src/index.js b/web-service/src/index.js index c6b37247a..a0f7f894b 100644 --- a/web-service/src/index.js +++ b/web-service/src/index.js @@ -32,8 +32,8 @@ function RGBDClient(peer, N, rate, dest) { /** * Actually send a frame over network to the client. */ -RGBDClient.prototype.push = function(uri, frame, ttime, chunk, rgb, depth) { - this.peer.send(uri, frame, ttime, chunk, rgb, depth); +RGBDClient.prototype.push = function(uri, latency, spacket, packet) { + this.peer.send(uri, latency, spacket, packet); this.txcount++; } @@ -58,14 +58,23 @@ function RGBDStream(uri, peer) { this.rxmax = 10; // Add RPC handler to receive frames from the source - peer.bind(uri, (frame, ttime, chunk, rgb, depth) => { + peer.bind(uri, (latency, spacket, packet) => { // Forward frames to all clients - this.pushFrames(frame, ttime, chunk, rgb, depth); + this.pushFrames(latency, spacket, packet); this.rxcount++; if (this.rxcount >= this.rxmax && this.clients.length > 0) { this.subscribe(); } }); + + /*peer.bind(uri, (frame, ttime, chunk, rgb, depth) => { + // Forward frames to all clients + this.pushFrames(frame, ttime, chunk, rgb, depth); + this.rxcount++; + if (this.rxcount >= this.rxmax && this.clients.length > 0) { + this.subscribe(); + } + });*/ } RGBDStream.prototype.addClient = function(peer, N, rate, dest) { @@ -88,12 +97,12 @@ RGBDStream.prototype.subscribe = function() { this.peer.send("get_stream", this.uri, 10, 0, [Peer.uuid], this.uri); } -RGBDStream.prototype.pushFrames = function(frame, ttime, chunk, rgb, depth) { - this.rgb = rgb; - this.depth = depth; +RGBDStream.prototype.pushFrames = function(latency, spacket, packet) { + if (spacket[1] & 0x1) this.depth = packet[4]; + else this.rgb = packet[4]; for (let i=0; i < this.clients.length; i++) { - this.clients[i].push(this.uri, frame, ttime, chunk, rgb, depth); + this.clients[i].push(this.uri, latency, spacket, packet); } let i=0; -- GitLab