Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
ftl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Nicolas Pope
ftl
Commits
8e8ee38e
Commit
8e8ee38e
authored
4 years ago
by
Nicolas Pope
Browse files
Options
Downloads
Patches
Plain Diff
Some corrections to web service, essentially working
parent
ea839f92
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#26585
passed
4 years ago
Stage: all
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
web-service/server/src/index.js
+31
-20
31 additions, 20 deletions
web-service/server/src/index.js
web-service/server/src/peer.js
+4
-1
4 additions, 1 deletion
web-service/server/src/peer.js
with
35 additions
and
21 deletions
web-service/server/src/index.js
+
31
−
20
View file @
8e8ee38e
...
...
@@ -42,12 +42,8 @@ let peer_data = [];
* @param {number} rate Bitrate index requested
* @param {string} dest URI destination
*/
function
RGBDClient
(
peer
,
N
,
rate
,
dest
)
{
function
RGBDClient
(
peer
)
{
this
.
peer
=
peer
;
this
.
txmax
=
N
*
16
;
// 16 is for 16 blocks per frame... this will change in the near future
this
.
rate
=
rate
;
this
.
dest
=
dest
;
this
.
txcount
=
0
;
}
/**
...
...
@@ -55,7 +51,7 @@ function RGBDClient(peer, N, rate, dest) {
*/
RGBDClient
.
prototype
.
push
=
function
(
uri
,
latency
,
spacket
,
packet
)
{
this
.
peer
.
send
(
uri
,
latency
,
spacket
,
packet
);
this
.
txcount
++
;
//
this.txcount++;
}
/**
...
...
@@ -82,10 +78,10 @@ function RGBDStream(uri, peer) {
peer
.
bind
(
uri
,
(
latency
,
spacket
,
packet
)
=>
{
// Forward frames to all clients
this
.
pushFrames
(
latency
,
spacket
,
packet
);
this
.
rxcount
++
;
if
(
this
.
rxcount
>=
this
.
rxmax
&&
this
.
clients
.
length
>
0
)
{
this
.
subscribe
();
}
//
this.rxcount++;
//
if (this.rxcount >= this.rxmax && this.clients.length > 0) {
//
this.subscribe();
//
}
});
/*peer.bind(uri, (frame, ttime, chunk, rgb, depth) => {
...
...
@@ -98,17 +94,18 @@ function RGBDStream(uri, peer) {
});*/
}
RGBDStream
.
prototype
.
addClient
=
function
(
peer
,
N
,
rate
,
dest
)
{
RGBDStream
.
prototype
.
addClient
=
function
(
peer
)
{
// TODO(Nick) Verify that it isn't already in list...
for
(
let
i
=
0
;
i
<
this
.
clients
.
length
;
i
++
)
{
if
(
this
.
clients
[
i
].
peer
.
string_id
==
peer
.
string_id
)
return
;
//if (this.clients[i].peer.string_id == peer.string_id) return;
if
(
this
.
clients
[
i
].
peer
===
peer
)
return
;
}
this
.
clients
.
push
(
new
RGBDClient
(
peer
,
N
,
rate
,
dest
));
console
.
log
(
"
MINMAX
"
,
this
.
rxcount
,
this
.
rxmax
);
if
(
this
.
rxcount
>=
this
.
rxmax
)
{
this
.
subscribe
();
}
this
.
clients
.
push
(
new
RGBDClient
(
peer
));
//
console.log("MINMAX", this.rxcount, this.rxmax);
//
if (this.rxcount >= this.rxmax) {
//
this.subscribe();
//
}
}
RGBDStream
.
prototype
.
subscribe
=
function
()
{
...
...
@@ -133,13 +130,13 @@ RGBDStream.prototype.pushFrames = function(latency, spacket, packet) {
this
.
clients
[
i
].
push
(
this
.
uri
,
latency
,
spacket
,
packet
);
}
let
i
=
0
;
/*
let i=0;
while (i < this.clients.length) {
if (this.clients[i].txcount >= this.clients[i].txmax) {
console.log("remove client");
this.clients.splice(i, 1);
} else i++;
}
}
*/
}
// ---- PROTOCOL ---------------------------------------------------------------
...
...
@@ -329,7 +326,21 @@ app.ws('/', (ws, req) => {
p
.
bind
(
"
find_stream
"
,
(
uri
)
=>
{
const
parsedURI
=
stringSplitter
(
uri
)
if
(
uri_to_peer
.
hasOwnProperty
(
parsedURI
))
{
console
.
log
(
"
Stream found:
"
,
uri
);
console
.
log
(
"
Stream found:
"
,
uri
,
parsedURI
);
if
(
!
p
.
isBound
(
uri
))
{
console
.
log
(
"
Adding local stream binding
"
);
p
.
bind
(
uri
,
(
ttimeoff
,
spkt
,
pkt
)
=>
{
console
.
log
(
"
STREAM:
"
,
spkt
);
let
speer
=
uri_to_peer
[
parsedURI
];
if
(
speer
)
{
uri_data
[
parsedURI
].
addClient
(
p
);
speer
.
send
(
parsedURI
,
ttimeoff
,
spkt
,
pkt
);
}
else
if
(
speer
)
console
.
log
(
"
Stream response
"
);
else
console
.
error
(
"
No stream peer
"
);
});
}
return
[
Peer
.
uuid
];
}
else
{
console
.
log
(
"
Stream not found:
"
,
uri
)
...
...
This diff is collapsed.
Click to expand it.
web-service/server/src/peer.js
+
4
−
1
View file @
8e8ee38e
...
...
@@ -40,7 +40,6 @@ function Peer(ws) {
this
.
master
=
false
;
let
message
=
(
raw
)
=>
{
// console.log(raw)
//Gets right data for client
if
(
this
.
sock
.
on
===
undefined
){
raw
=
raw
.
data
;
...
...
@@ -185,6 +184,10 @@ Peer.prototype.bind = function(name, f) {
}
}
Peer
.
prototype
.
isBound
=
function
(
name
)
{
return
this
.
bindings
.
hasOwnProperty
(
name
)
||
this
.
proxies
.
hasOwnProperty
(
name
);
}
/**
* Allow an RPC call to pass through to another machine with minimal local
* processing.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment