mirror of
https://github.com/HSLdevcom/digitransit-ui
synced 2025-07-30 19:35:55 +02:00
27 lines
815 B
JavaScript
27 lines
815 B
JavaScript
import { startMqttClient, changeTopics } from '../util/mqttClient';
|
|
|
|
export function startRealTimeClient(actionContext, settings, done) {
|
|
/* settings may have changed, so reset old store content */
|
|
if (actionContext.config.NODE_ENV === 'test') {
|
|
return;
|
|
}
|
|
actionContext.dispatch('RealTimeClientReset');
|
|
startMqttClient(settings, actionContext).then(data => {
|
|
actionContext.dispatch('RealTimeClientStarted', data);
|
|
done();
|
|
});
|
|
}
|
|
|
|
export function stopRealTimeClient(actionContext, client, done) {
|
|
client.end();
|
|
actionContext.dispatch('RealTimeClientStopped');
|
|
done();
|
|
}
|
|
|
|
export function changeRealTimeClientTopics(actionContext, settings, done) {
|
|
// remove existing vehicles/topics
|
|
actionContext.dispatch('RealTimeClientReset');
|
|
|
|
changeTopics(settings, actionContext);
|
|
done();
|
|
}
|