Bridge events

This commit is contained in:
Stian Fredrik Aune
2021-05-24 10:31:31 +02:00
parent 883115bf8b
commit a2e719def9
7 changed files with 111 additions and 9 deletions
+2 -2
View File
@@ -195,9 +195,9 @@ func (b *bridge) Run(ctx context.Context, info models.Bridge, ch chan<- models.E
defer conn.Close()
// Notify connections and disconnections
ch <- models.Event{Name: "BridgeConnected", Payload: map[string]string{"bridgeId": strconv.Itoa(info.ID)}}
ch <- models.BridgeConnectedEvent(info)
defer func() {
ch <- models.Event{Name: "BridgeDisconnected", Payload: map[string]string{"bridgeId": strconv.Itoa(info.ID)}}
ch <- models.BridgeDisconnectedEvent(info)
}()
// Start touch listener. This one should go down together with this one, though, so it needs a new context.