Add topic publishing sidebar

This commit is contained in:
Thomas Nordquist
2019-01-11 00:40:05 +01:00
parent eb375073f9
commit c3ef9335c0
13 changed files with 292 additions and 15 deletions

View File

@@ -1,7 +1,7 @@
import {
addMqttConnectionEvent, backendEvents,
makeConnectionStateEvent, removeConnection,
makeConnectionMessageEvent, AddMqttConnection,
makeConnectionMessageEvent, makePublishEvent, AddMqttConnection, Message,
} from '../../events'
import { MqttSource, DataSource } from './DataSource'
@@ -26,6 +26,9 @@ class ConnectionManager {
connection.connect(options)
this.handleNewMessagesForConnection(connectionId, connection)
backendEvents.subscribe(makePublishEvent(connectionId), (msg: Message) => {
this.connections[connectionId].publish(msg.topic, msg.payload)
})
}
private handleNewMessagesForConnection(connectionId: string, connection: MqttSource) {