socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

make interface match browser WebSocket class?

Open jkarneges opened this issue 9 years ago • 2 comments

The engine.io client is so close to a polyfill for the browser WebSocket class that I wonder if it shouldn't match the interface? E.g. setting callbacks with onmessage = func instead of on('message', func) and so on. This way, projects that use the WebSocket class could support the engine.io client via simple dependency injection, rather than having to be made specifically aware of engine.io.

jkarneges avatar Apr 18 '16 06:04 jkarneges

Apparently it even used to work this way: http://www.devthought.com/2012/07/07/the-realtime-engine/

Would a patch to support the WebSocket interface be accepted?

jkarneges avatar May 18 '16 04:05 jkarneges

We went ahead and made a wrapper to emulate the WebSocket class. Here it is if anyone's interested: https://github.com/fanout/engine.io-as-websocket

jkarneges avatar May 20 '16 08:05 jkarneges