Skip to content
Snippets Groups Projects
Commit 25af6c8f authored by IsolatedSushi's avatar IsolatedSushi
Browse files

Documenting

parent 865c3340
No related branches found
No related tags found
1 merge request!10Web socket streaming
......@@ -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(){
......
......@@ -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++) {
......
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