@Beta public interface DeviceConnect extends HandlerBehaviour
Modifier and Type | Method and Description |
---|---|
boolean |
connect()
Connects to the device, for example by opening the transport session that
will be later used to send control messages.
|
void |
disconnect()
Disconnects from the device, for example closing any transport session
previously opened.
|
boolean |
hasConnection()
Returns true if a connection to the device exists, false otherwise.
|
handler, setHandler
boolean connect() throws IllegalStateException
The implementation should trigger without blocking any necessary
handshake with the device to initialize the connection over the network,
eventually generating a DeviceAgentEvent.Type.CHANNEL_OPEN
event when ready.
When calling this method while a connection to the device already exists,
the behavior is not defined. For example, some implementations might
require to first call disconnect()
, while other might behave as
a no-op.
IllegalStateException
- if a connection already exists and the
implementation requires to call disconnect()
first.boolean hasConnection()
In general, when called after connect()
it should always return
true, while it is expected to always return false after calling disconnect()
or if connect()
was never called.
void disconnect()
Calling multiple times this method while a connection to the device is already closed should result in a no-op.
If a connection to the device existed and it was open, the implementation
is expected to generate a
DeviceAgentEvent.Type.CHANNEL_CLOSED
event.