In WebSocketClient, the connect/close latches will count down before the callback is called:
public final void onWebsocketOpen( WebSocket conn, Handshakedata handshake ) {
connectLatch.countDown();
onOpen( (ServerHandshake) handshake );
}
This means the blocking methods will return before the callback is called. If the consumer of the client interface does something on open that is required before proceeding, there is a race condition where the callback action may not happen soon enough. For example:
public class ClientConsumer {
@Override
public void onOpen(final ServerHandshake handshake) {
m_Log.info("Connected to MessageServer: %s", getURI());
m_Connected = true;
}
public connect() {
client.connectBlocking();
}
public send() {
if (m_Connected) {
client.send(...);
}
}
ClientConsumer c;
c.connect(); // will return before m_Connect is set possibly
c.send(); // will not always send since m_Connect may still be false
This is a simplified example. Our actual wrapper code has more to it.
In WebSocketClient, the connect/close latches will count down before the callback is called:
This means the blocking methods will return before the callback is called. If the consumer of the client interface does something on open that is required before proceeding, there is a race condition where the callback action may not happen soon enough. For example:
This is a simplified example. Our actual wrapper code has more to it.