What does the method switchToAlternateConnection do exactly?
Does it call a blocking operation such as wait() or similar commands?
Indeed you don’t need to block a thread in order to wait for the connected status. You can simply create a new client (or reuse the old one) and register a ClientListener.
For example:
void onStatusChange(String status) {
switch (status) {
case "DISCONNECTED":
var newClient = new LightstreamerClient(...)
newClient.addListener(
void onStatusChange(status) {
switch (status) {
case "CONNECTED:WS-STREAMING":
// complete the configuration
}
})
newClient.connect()
}
}
Since the methods of LightstreamerClient are asynchronous and reentrant, they work as expected.