- Send close frames on close() or on receipt of a close frame from the server. - Add a timeout option to close() to handle servers that don't properly support client-initiated close handshaking. - Re-jigger unit tests to avoid client-initiated closes, as the WS server that we're using doesn't support this.
- Also, explicitly close the HTTP client instance if we fail to connect.
The data for the onmessage event needs to match the MessageEvent interface: http://dev.w3.org/html5/websockets/#feedback-from-the-protocol ... which is defined here: http://www.whatwg.org/specs/web-apps/current-work/#event-definitions-0 This is the smallest possible change to make it work with SocketIO
- Work around behavioral differences in different NodeJS versions with respect 0-length buffers. Explicitly avoid attempting a copy() unless we're going to be operating on > 0 bytes. - Change 'error' event to 'wserror' to avoid EventEmitter throwing an error.
- The lo-byte parser would incorrectly call buf.copy() with an offset at the end of the target buffer and a length of 0. Though this is theoretically a no-op, Buffer.copy() is doing bounds-checking on the source before taking the length into account. - Clear bufs and bufBytes when consuming partial buffer.