pbuda/scalawebsocket — pull request #1 by marcsaegesser (2013-12-09 22:16:26+00:00)
Title: New onOpen/onClose behavior

The onOpen handlers can be invoked before the WebSocket instance is fully initialized. The ws value is set in open() when the future returned by execute() completes but the onOpen callback can be invoked before that. This can result in a NullPointerException if a call is made to a method like sendText() in response to receiving an onOpen callback.

This pull request moves the invocation of the onOpen handlers into open() after the the ws value is initialized. Also, the onOpen and onClose handlers now supply a scalawebsocket.WebSocket value as their parameter. This prevents leaking the underlying AsyncHttpClient WebSocket value outside the implementation.