You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I try to open a connection right before sending a message, but didn't find a way to get hold of a Future which will be completed, once the connection to a server has been established, so had to resort to busy waiting:
void send(IsoMessage message) throws InterruptedException {
reconnectIfNecessary();
client.send(message);
}
private void reconnectIfNecessary() throws InterruptedException {
if (!client.isConnected()) {
client.connect();
}
waitForConnection();
}
@SuppressWarnings("BusyWait")
private void waitForConnection() throws InterruptedException {
int retry = 0;
while (!client.isConnected()) {
checkState(retry < 10, "Client channel is not connected after %s ms", retry * 100);
Thread.sleep(100);
retry++;
}
}
There sure must be a better way of handling this?
The text was updated successfully, but these errors were encountered:
Hi Pavlov,
I try to open a connection right before sending a message, but didn't find a way to get hold of a
Future
which will be completed, once the connection to a server has been established, so had to resort to busy waiting:There sure must be a better way of handling this?
The text was updated successfully, but these errors were encountered: