简体   繁体   English

针对socket.io的engine.io优势

[英]advantage engine.io towards socket.io

I'm new to node.js and set up a simple chat application with socket.io. 我是node.js的新手,并使用socket.io设置了一个简单的聊天应用程序。 I realizied the installed modules together with express need 30MB. 我实现了已安装的模块以及快递需要30MB。 Is engine.io more slim? engine.io更苗条了吗? does it has advantages towards use engine.io ? 它有使用engine.io的优势吗?

Engine.io is more of a lower library of Socket.io. Engine.io更像是一个较低的Socket.io库。 If you want the lower level abstraction use engine, if you want a websocket abstraction keep using socket.io. 如果你想要低级抽象使用引擎,如果你想要一个websocket抽象继续使用socket.io。 Engine.io is of more interest to you if your building a library/framework on top of socket.io. 如果您在socket.io上构建一个库/框架,那么Engine.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. 与之前的socket.io核心不同,它始终首先建立长轮询连接,然后尝试升级到侧面“测试”的更好的传输。 The main goal of Engine is ensuring the most reliable realtime communication. Engine的主要目标是确保最可靠的实时通信。 Unlike the previous socket.io core which rely on HTML5 websockets and Flash socket as the first communcation mechanism. 不同于以前的socket.io核心,它依赖于HTML5 websockets和Flash socket作为第一个通信机制。 You can also use this to set the order in socket.io 您也可以使用它来设置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. IE,Android <4.0并不是每个IOS都不支持WebSocket,所以最好让它回退到XHR轮询。

http://caniuse.com/#search=websockets 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. Android拥有可以包含的Java库,以使websocket适用于Android 2.3,但运行速度相当慢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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