Registering the Callback Object
You use the BrokerServerClient.registerConnectionCallback method to register a method you want to be called in the event your Broker client is disconnected or reconnected to its Broker. This method accepts two parameters. The first parameter is the BrokerConnectionCallback-derived object that implements your callback method. The second parameter is a client_data object, which is used to pass any needed data to the callback method.
Note:
Any callback objects previously registered for a Broker client will be replaced by the one currently being registered.
When the BrokerServerConnectionCallback object's the callback method is invoked, that method's connect_state parameter will be set to one of the following BrokerClient-defined values shown in the following table.
connect_state | Meaning |
CONNECT_STATE_CONNECTED | The Client connection has been re-established, because automatic reconnect was enabled. |
CONNECT_STATE_DISCONNECTED | The client has been disconnected. |
CONNECT_STATE_RECONNECTED | The Client was disconnected, but the connection was re-established immediately. This only happens if the automatic reconnect feature is enabled and the connection is re-established before a disconnected state can be reported. |