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
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
vig
provee
dummy-vue-grpc
Commits
25af6c8f
Commit
25af6c8f
authored
4 years ago
by
IsolatedSushi
Browse files
Options
Downloads
Patches
Plain Diff
Documenting
parent
865c3340
No related branches found
No related tags found
1 merge request
!10
Web socket streaming
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
backend/gRPCProjector/src/grpcServer.js
+4
-0
4 additions, 0 deletions
backend/gRPCProjector/src/grpcServer.js
backend/webSocketGateway/src/webSocketGateway.js
+5
-1
5 additions, 1 deletion
backend/webSocketGateway/src/webSocketGateway.js
with
9 additions
and
1 deletion
backend/gRPCProjector/src/grpcServer.js
+
4
−
0
View file @
25af6c8f
...
...
@@ -28,6 +28,7 @@ function main() {
});
}
main
();
var
pointID
=
0
;
function
generatePoint
()
{
const
id
=
pointID
++
;
...
...
@@ -37,6 +38,7 @@ function generatePoint() {
return
{
id
,
x
,
y
};
}
//The client calls this
function
getProjectionPoints
(
call
){
console
.
log
(
"
connected
"
);
call
.
on
(
'
data
'
,(
msg
)
=>
{
...
...
@@ -53,12 +55,14 @@ function getProjectionPoints(call){
});
}
//Send the point back
function
echoPoint
(
call
,
hdvector
){
var
response
=
{
id
:
pointID
,
x
:
hdvector
[
0
],
y
:
hdvector
[
1
]};
call
.
write
(
response
);
pointID
+=
1
;
}
//In case of no points
function
sendProjectionPoints
(
call
){
console
.
log
(
"
Sending generated points
"
);
var
intervalId
=
setInterval
(
function
(){
...
...
This diff is collapsed.
Click to expand it.
backend/webSocketGateway/src/webSocketGateway.js
+
5
−
1
View file @
25af6c8f
...
...
@@ -53,6 +53,7 @@ wss.on('connection', function connection(_ws) {
});
});
//Parse the message from browser
function
parseMessage
(
message
)
{
const
jsonMessage
=
JSON
.
parse
(
message
);
...
...
@@ -71,7 +72,7 @@ function parseMessage(message) {
}
//Echo point back from the gateway
function
echoPoint
(
dataRow
)
{
ws
.
send
(
JSON
.
stringify
({
"
id
"
:
dataRow
[
0
]
...
...
@@ -81,12 +82,14 @@ function echoPoint(dataRow) {
}));
}
//Get the stream
function
getPointStream
()
{
var
trainingSetRow
=
{
id
:
"
0
"
,
hdvector
:
null
};
call
.
write
(
trainingSetRow
);
console
.
log
(
"
stream
"
)
}
//Send row to microservice
function
sendRowToServer
(
row
)
{
var
hdvector
=
[];
for
(
var
i
=
1
;
i
<
row
.
length
;
i
++
){
...
...
@@ -97,6 +100,7 @@ function sendRowToServer(row) {
call
.
write
(
trainingSetRow
);
}
//Send client to browser
function
sendDataStreamToClient
(
data
)
{
var
list
=
data
.
toString
().
trim
().
split
(
"
\n
"
);
for
(
var
i
=
0
;
i
<
list
.
length
;
i
++
)
{
...
...
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