dissertation/where_fi/visualise/frontend/connect/index.ts
Christos Falas 298146e8b0
add proto files for streaming
The idea is to allow relatively flexible visualisations in the browser,
while minimising rendering load on the server.
2025-02-22 10:21:50 +00:00

24 lines
705 B
TypeScript

import { FigureRequest, FigureUpdate } from './figure_pb.js';
import { FigureServiceClient } from './FigureServiceClientPb';
export function connect(host: string) {
var figureService = new FigureServiceClient(host);
var request = new FigureRequest();
var stream = figureService.getFigure(request);
stream.on('data', function(response: FigureUpdate) {
if (response.hasFigure()) {
console.log("Got new figure");
}
else {
console.log("Got figure update");
}
});
stream.on('status', function(status: any) {
console.log("Status:", status);
});
stream.on('end', function() {
console.log("End");
});
}