简体   繁体   中英

advantage engine.io towards socket.io

I'm new to node.js and set up a simple chat application with socket.io. I realizied the installed modules together with express need 30MB. Is engine.io more slim? does it has advantages towards use engine.io ?

Engine.io is more of a lower library of Socket.io. If you want the lower level abstraction use engine, if you want a websocket abstraction keep using socket.io. Engine.io is of more interest to you if your building a library/framework on top of socket.io. Unlike the previous socket.io core, it always establishes a long-polling connection first, then tries to upgrade to better transports that are "tested" on the side. The main goal of Engine is ensuring the most reliable realtime communication. Unlike the previous socket.io core which rely on HTML5 websockets and Flash socket as the first communcation mechanism. You can also use this to set the order in socket.io

io.set('transports', [ 'websocket', 'xhr-polling' ]);

WebSocket isn't supported by IE, Android < 4.0 and not every IOS so it's good to have it fallback to XHR-polling.

http://caniuse.com/#search=websockets

Android has Java libraries that can be included to get websockets working for Android 2.3 but it runs rather slow.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM