Your websockets do some good stuff but, for consistencies sake and perhaps some browserify action, I wanted to use the W3CWebsocket interface with a server connection. I had forked your project a while ago but I suppose I wasn't able to figure out how to get it done. Well, I got it done.
Notes
connection2w3cwebsocket is a very simple function
W3CWebSocket now inherits W3CWebSocketWrapper and much of the guts have been moved over there
Right now, W3CWebSocket listens to the close event to cleanup it's client.
this covers client failure, close while connecting and normal closing
If ever a consumer decided to remove all event listeners for this, the client will not get cleaned up.
This is also the case for some of the connection close events. Hopefully, nobody does something silly
I didn't know what to name W3CWebSocketWrapper
I added some tests, effectively just copied the W3CWebSocket tests.
the server based W3CWebSocket doesn't emit an open event.
I considered doing a Promise.resolve() then opening it but I'm not sure if its relevant
I'm definitely open to to implementing one if that is important it really should be easy
Your websockets do some good stuff but, for consistencies sake and perhaps some browserify action, I wanted to use the W3CWebsocket interface with a server connection. I had forked your project a while ago but I suppose I wasn't able to figure out how to get it done. Well, I got it done.
Notes
W3CWebSocket
now inheritsW3CWebSocketWrapper
and much of the guts have been moved over thereW3CWebSocket
listens to the close event to cleanup it's client.