The DOFConnection.StateListener is used to track the state of any DOFConnection. In this example, we print a message when the state of the connection changes (i.e., connects or disconnects). This is done by implementing the stateChanged method in the DOFConnection.StateListener.
Earlier in the training, we created DOFServer and DOFConnection instances using synchronous start and connect calls. However, the library also provides non-blocking asynchronous calls that you can use for this purpose.
You can also use connection and server state listeners to monitor the status of your components. These allow you to attempt to restart the server or reconnect the connection if they go down.
Note: The code for the connection state listener is similar to the server state listener.
The connection state listener is an interface with the following callbacks:
DOFConnection.StateListener is used primarily to track the connection state.