infoscreens/lib/liveupdate.js
2017-12-04 18:43:12 +01:00

13 lines
375 B
JavaScript

export function subscribe(timeseries, callback) {
const socket = new WebSocket('ws://openmct.cbrp3.c-base.org:8082/');
socket.addEventListener('open', () => {
timeseries.forEach((series) => {
socket.send(`subscribe ${series}`);
});
});
socket.addEventListener('message', (msg) => {
callback(JSON.parse(msg.data));
});
}
export default subscribe;