So currently we disconnect all connections after every folder related change, namely folder being un-ignored, folder being paused, folder being removed, unpaused, added.
The protocol also mandates that there should be a single ClusterConfig message ever per connection, which I guess is why we do it.
I’d like to change that, and change the spec.
It seems that if a device receives a second ClusterConfig message, it will close the connection itself:
switch msg := msg.(type) {
case *ClusterConfig:
l.Debugln("read ClusterConfig message")
if state != stateInitial {
return fmt.Errorf("protocol error: cluster config message in state %d", state)
}
c.receiver.ClusterConfig(c.id, *msg)
state = stateReady
so I think it’s safe to start sending secondary ClusterConfig messages for new devices, and they should be handled the same way for old devices (instead of us disconnecting, the other side will disconnect on a protocol error).
Also, I know @imsodin did a lot of clever tricks fixing ClusterConfig for non-existing devices etc, I guess I’d have to relax the tricks for other-than-first ClusterConfig messages, as I suspect out of bound, post close ClusterConfig messages will become possible.
This does not fix anything in particular, just potentially makes these operations more smooth.
Thoughts?