Uh, this might actually not be a good idea because the SockJS and WebSocket constants don't match. SockJS has an additional CLOSING state.

My comment above actually did not make sense. If SockJS had the constants on the prototype and not on the constructor we could just do this.socket.readyState == this.socket.CONNECTING. But SockJS does not follow the WebSocket specs here. Will create a pull request.