PlaceOS/driver

`set_connected_state` behaviour of `status_only`

Closed this issue · 0 comments

There was some discussion on this on slack previously, but logging here as something to revisit as it keeps popping up (at least for me).

Calling set_connected_state true, status_only: false directly invokes the connected callback. Passing status_only: true does not unless there is a state change.

def set_connected_state(online, status_only = true)
online = !!online
if status_only
@__queue__.set_connected(online)
else
@__queue__.online = online
end
end

This is due to the behaviour of PlaceOS::Driver::Queue. The status_only param toggles if the queue online state should update and runs the callback on state change only.

This is the desired behaviour for the driver framework, but confusing naming for anyone using it as the semantics imply that status_only should flick status, but not execute behaviour.