TooTallNate/Java-WebSocket — Issue #56: first message lost if send() called before onOpen()
Author: donpdonp
Created: 2011-12-22 22:55:39+00:00
State: open

1. open websocket to a service that sends "hello" immediately upon connection.
2. send() a message before the onOpen() callback is fired.

With this setup, onMessage() does not receive the 'hello' message. It does receive subsequent messages, after onOpen() completes.

By adding a boolean "connected" flag to the WebSocketClient subclass (set true in onOpen() and false in onClose()) and protecting the application's calls to send() with an isConnected() check, this allows the 'hello' message to be received.