infoscreens/lib/liveupdate.js

14 lines
375 B
JavaScript
Raw Permalink Normal View History

2017-12-04 18:43:12 +01:00
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;