diff --git a/broker.go b/broker.go index 2e43a32..3c793c1 100644 --- a/broker.go +++ b/broker.go @@ -133,12 +133,16 @@ func (br *broker) run() { c.Close() if c.IsDevice() { - if !c.(*device).registered { + dev := c.(*device) + + if !dev.registered { break } delete(br.devices, devid) + dev.registered = false + for sid, s := range br.sessions { if s.dev == c { s.user.Close()