SockJS 还是 Socket.IO?值得重新编码基于 ajax 的页面吗? [英] SockJS or Socket.IO? Worth to recode ajax-based page?

查看:93
本文介绍了SockJS 还是 Socket.IO?值得重新编码基于 ajax 的页面吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

哪个更好:Socket.IOSockJS 和最大的区别是什么?

Which one's better: Socket.IO or SockJS and what are the biggest differences?

将一个完全基于ajax的页面重建成一个基于node.JS/socket.io的页面有多难?我是否必须完全重新编码所有内容?有没有关于如何做到这一点的好教程?值得这样做吗(在您看来)?

How difficult is it to rebuild a completely ajax based page into a node.JS / socket.io based page? Do I have to recode absolutely everything? Are there any good tutorials on how to do this? Is it worth to do it (in your opinion)?

推荐答案

SockJS 有更多可用的服务器端选项.如果您不想绑定到 Node.js,那么它可能是一种选择.从使用 PyPy 托管服务器端部分的一些基准测试来看,缩放似乎效果最好.

SockJS has more server-side options available. If you don't want to be tied to Node.js, then it may be an option. The scaling seems to work best, from some benchmarks using PyPy to host the server-side portion.

socket.io 有更多传输选项,包括 Flash.即使您不喜欢 Flash,它也可以选择真正的 WebSocket 传输,这可能会根据您的实施需求更好地工作.

socket.io has more transport options, which include Flash. Even if you don't like flash, it does have the option for a real WebSocket transport, which may work better depending on your implementation desires.

事实是,要么完成工作,这取决于您的愿望.我建议在每个应用程序中创建一个简单的应用程序,看看你的 API 是否更自然.

The fact is, either will get the job done, it just depends on your desires. I would suggest creating a trivial application in each, and see if one's APIs feel more natural to you.

就我个人而言,我更倾向于使用 socket.io ... 我还要说,如果您需要使用集群进行扩展,您可能还需要制定使用发布/订阅服务器的策略(例如如 redis),因为不同的请求可能会到达不共享内存状态的不同进程.

Personally, I'm more inclined to use socket.io ... I will also say that if you need to scale using clusters, you will probably also need to map out a strategy to use a pub/sub server (such as redis) as different requests may come to different processes that don't share memory state.

另外值得注意的是,.Net 是否有一个类似的框架叫做 SignalR ...

Also worth noting, is there is a similar framework for .Net called SignalR ...

这篇关于SockJS 还是 Socket.IO?值得重新编码基于 ajax 的页面吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆