addConnectionStatusHandler

public final Unit addConnectionStatusHandler(String identifier, ConnectionStatusHandler handler)

Adds a connection status handler.

Notifies via ConnectionStatusHandler.onConnectionStatusChanged when the connection status changes.

NCEngine.addConnectionStatusHandler("CONNECTION_HANDLER_ID") { event ->
when (event.status) {
ConnectionStatus.CONNECTED -> println("Connected")
ConnectionStatus.SUSPENDED -> println("Connection suspended")
else -> println("Status: ${event.status}")
}
}

Parameters

identifier

Unique identifier for the handler, used for subsequent removal

handler

Connection status handler