Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dummy-vue-grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vig
provee
dummy-vue-grpc
Commits
a8e5fee5
Commit
a8e5fee5
authored
Dec 14, 2020
by
IsolatedSushi
Browse files
Options
Downloads
Patches
Plain Diff
Added random points again
parent
a42d0902
No related branches found
No related tags found
1 merge request
!10
Web socket streaming
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/gRPCProjector/src/grpcServer.js
+8
-3
8 additions, 3 deletions
backend/gRPCProjector/src/grpcServer.js
backend/webSocketGateway/src/webSocketGateway.js
+12
-14
12 additions, 14 deletions
backend/webSocketGateway/src/webSocketGateway.js
with
20 additions
and
17 deletions
backend/gRPCProjector/src/grpcServer.js
+
8
−
3
View file @
a8e5fee5
...
...
@@ -41,14 +41,19 @@ function getProjectionPoints(call){
console
.
log
(
"
connected
"
);
call
.
on
(
'
data
'
,(
msg
)
=>
{
console
.
log
(
msg
.
hdvector
);
if
(
msg
.
hdvector
.
length
>
0
){
echoPoint
(
call
,
msg
.
hdvector
);
}
else
{
sendProjectionPoints
(
call
);
}
});
call
.
on
(
'
end
'
,()
=>
{
console
.
log
(
"
end
"
);
});
}
function
echoPoint
(
call
,
hdvector
){
var
response
=
{
id
:
pointID
,
x
:
hdvector
[
0
],
y
:
hdvector
[
1
]};
call
.
write
(
response
);
...
...
...
...
This diff is collapsed.
Click to expand it.
backend/webSocketGateway/src/webSocketGateway.js
+
12
−
14
View file @
a8e5fee5
...
...
@@ -49,22 +49,22 @@ main();
wss
.
on
(
'
connection
'
,
function
connection
(
_ws
)
{
console
.
log
(
`Client connected with websocket`
);
ws
=
_ws
;
_
ws
.
on
(
'
message
'
,
function
incoming
(
message
)
{
parseMessage
(
_ws
,
message
);
ws
.
on
(
'
message
'
,
function
incoming
(
message
)
{
parseMessage
(
message
);
});
});
function
parseMessage
(
_ws
,
message
)
{
function
parseMessage
(
message
)
{
const
jsonMessage
=
JSON
.
parse
(
message
);
switch
(
jsonMessage
[
"
type
"
])
{
case
"
requestPointStream
"
:
console
.
log
(
"
Requested stream
"
);
getPointStream
(
_ws
);
getPointStream
();
break
;
case
"
sendDataRow
"
:
sendRowToServer
(
jsonMessage
[
"
row
"
]);
//echoPoint(
ws,
jsonMessage["row"]);
//echoPoint(jsonMessage["row"]);
break
;
default
:
console
.
log
(
"
Error! Unknown request:
"
+
jsonMessage
[
"
type
"
]);
...
...
@@ -73,9 +73,9 @@ function parseMessage(_ws, message) {
function
echoPoint
(
_ws
,
dataRow
)
{
function
echoPoint
(
dataRow
)
{
console
.
log
(
dataRow
);
_
ws
.
send
(
JSON
.
stringify
({
ws
.
send
(
JSON
.
stringify
({
"
id
"
:
dataRow
[
0
]
,
"
x
"
:
dataRow
[
1
],
"
y
"
:
dataRow
[
2
]
...
...
@@ -83,12 +83,12 @@ function echoPoint(_ws, dataRow) {
}));
}
function
getPointStream
(
_ws
)
{
function
getPointStream
()
{
var
trainingSetRow
=
{
id
:
"
0
"
,
hdvector
:
null
};
call
.
write
(
trainingSetRow
);
console
.
log
(
"
stream
"
)
}
function
sendRowToServer
(
row
)
{
var
hdvector
=
[];
row
.
forEach
((
el
)
=>
{
...
...
@@ -99,9 +99,7 @@ function sendRowToServer(row) {
call
.
write
(
trainingSetRow
);
}
function
sendDataStreamToClient
(
data
,
ws
)
{
function
sendDataStreamToClient
(
data
)
{
var
list
=
data
.
toString
().
trim
().
split
(
"
\n
"
);
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
try
{
...
...
...
...
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