实时网络库 - 用 socket.io 替换 hookbox 还是什么?

发布于 2024-11-24 02:21:19 字数 558 浏览 2 评论 0原文

我有几个使用 hookbox 构建的项目来管理 Web 客户端和服务器之间的实时消息传递。 Hookbox 很棒——它完全抽象了传输层,通过优雅的安全系统在不同的通道上公开了一个简单的发布/订阅接口。

不幸的是,由于原始维护者甚至不愿意付出努力来交出所有权,hookbox 项目很快就陷入了混乱。 (哎呀!)所以很难再将其视为一个可行的平台。

什么是提供与网络应用程序实时通信的好平台?要求:

  • 跨浏览器无缝运行,使用 HTML5 websockets 或 COMET。传输选择对于应用层来说应该是不可见的。我不关心古老的浏览器(IE6)
  • 从 javascript 和服务器端系统(即在 php / python / ruby​​ 中)进行客户端访问 - 这很关键
  • 提供具有任意有效负载的发布/订阅隐喻
  • 允许客户端查看其他内容客户端连接到一个通道,即存在
  • 通过回调任何 Web 应用程序进行细粒度访问控制(很好)

我听说 socket.io 可以做到其中一些,但我感觉它位于较低层的堆栈。它可以连接到非 javascript 库吗?做授权吗?

I've got a couple projects that were built using hookbox to manage real-time message passing between web clients and servers. Hookbox was great -- it totally abstracted the transport layer, exposing a simple publish/subscribe interface across different channels with an elegant security system.

Unfortunately the hookbox project has rapidly fallen into disarray due to the original maintainer's unwillingness to even put in the effort to hand off ownership. (Grrr!) So it's hard to consider it a viable platform any more.

What's a good platform for providing real-time communication with web apps? Requirements:

  • Works seemlessly cross browser, using HTML5 websockets or COMET as available. Transport choice should be invisible to application layer. I don't care about ancient browsers (IE6)
  • Client access from both javascript and server-side systems (i.e. in php / python / ruby) -- this is critical
  • Provides a publish / subscribe metaphor with arbitrary payloads
  • Allows clients to see what other clients are connected to a channel, i.e. presence
  • Fine-grained access control through callbacks to any web application (nice to have)

I've heard that socket.io can do some of this, but I get the sense that it's at a lower layer of the stack. Can it connect to non-javascript libraries? Do auth?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

不顾 2024-12-01 02:21:19

我在 NodeJSSocket.IO 过去 8 个月。服务器端组件对我来说非常稳定 - 我可以让它以非常高的消息量运行,并且它的驻留内存永远不会真正超过 20MB。到目前为止,我只能让它运行大约 4 周而不终止服务器,但这只是因为我需要更新我的服务器端代码。

使用可用的 HTML5 websockets 或 COMET,跨浏览器无缝运行。传输选择对于应用层来说应该是不可见的。我不关心古老的浏览器(IE6)

提供具有任意负载的发布/订阅隐喻

Socket.IO 也是一个很棒的软件。它正在积极开发中,并具有使用“on”(订阅)和“emit”(发布)的 EventEmitter (NodeJS) 语义内置的简单的 pub/sub 风格抽象。关于所使用的传输,在客户端也是非常透明的。我主要将它用于直接 WebSocket 支持,但它可以回退到基于 Flash 的套接字、xhr 轮询和 jsonp 轮询。

从 JavaScript 和服务器端系统(即在 php / python / ruby​​ 中)进行客户端访问 - 这很关键

NodeJS 是 JavaScript,运行在 V8 引擎上。它有大量的第三方模块,它们提供了很好的抽象以及与外部的接口组件,例如数据库或消息队列等。至于使用 php/python/ruby 访问系统,它会像访问任何其他服务器一样工作。选择您的通信方法(基本 TCP/IP,或者 HTTP POST 或 GET,甚至通过文件系统),NodeJS 并不真正关心谁提供数据。就我个人而言,我实现了一个运行良好的 C# 客户端。

允许客户端查看哪些其他客户端连接到某个通道,即状态

它没有任何内置的“存在”逻辑,尽管 Socket.IO 中已经存在内置的“发布/订阅”逻辑,您可以所要做的就是在服务器上存储状态,以便新客户端可以检索现有的状态数据。我已经在保留状态的服务器上实现了自己的基本 pub/sub,并且所有这些(包括 NodeJS 服务器代码和基本的 Socket.IO 存根)总共只有 50 行 JavaScript(包括空格)。

通过回调任何 Web 应用程序进行细粒度访问控制(很高兴拥有)

不确定“通过对任何 Web 应用程序的回调进行细粒度访问控制(很高兴拥有)”是什么意思。他们的发布/订阅事件/观察者隐喻使用回调,因此您可以将特定操作挂钩到特定事件。

是否进行身份验证?

我还不需要对我们的系统进行任何身份验证,因此我无法直接与它对话。但是,如果您浏览 NodeJS 模块,您会注意到有许多可用的身份验证模块,包括 LDAP 和 OAuth,更不用说 一个模块声称可以执行“OpenId、Google、OAuth、Twitter、LinkedIn、Yahoo、Readability、Dropbox、Justin.tv、Vimeo、Tumblr、OAuth2、Facebook、 GitHub、Instagram、Foursquare、Box.net、LDAP”

I've had a very good experience with NodeJS and Socket.IO over the last 8 months. The server side component has been very stable for me - I can leave it running with a very high message volume and it's resident memory never really budges above 20MB. So far I've only been able to leave it running for about 4 weeks without terminating the server, but that was only because I needed to update my server side code.

Works seemlessly cross browser, using HTML5 websockets or COMET as available. Transport choice should be invisible to application layer. I don't care about ancient browsers (IE6)

Provides a publish / subscribe metaphor with arbitrary payloads

Socket.IO is also a fantastic piece of software. It under active development, and has a simple pub/sub style abstraction built in using EventEmitter (NodeJS) semantics of 'on' (subscribe) and 'emit' (publish). It is also very transparent on the client side regarding the transport being used. I used it primarily for the straight-up WebSocket support, but it can fall back to Flash based sockets, xhr-polling, and jsonp polling.

Client access from both javascript and server-side systems (i.e. in php / python / ruby) -- this is critical

NodeJS is JavaScript, running on the V8 engine. It has a ton of 3rd party modules that provide nice abstractions as well as interfacing with external components, such as a databases or message queues, among many other things. As far as hitting the system with php/python/ruby, it would work as with hitting any other server. Choose your method of communication (basic TCP/IP, or maybe HTTP POSTs or GETs, or even via filesystem) and NodeJS doesn't really care who is providing the data. Personally, I've implemented a C# client that is working great.

Allows clients to see what other clients are connected to a channel, i.e. presence

It doesn't not have any built in 'presence' logic, though with the built in 'pub/sub' logic already in place in Socket.IO, all you'd have to do is store state on the server so new clients can retrieve existing presence data. I've implemented my own basic pub/sub on the server that retains state, and all together (including the NodeJS server code, and the basic Socket.IO stubs) it was only 50 lines of JavaScript (including whitespace).

Fine-grained access control through callbacks to any web application (nice to have)

Not sure what you mean by 'Fine-grained access control through callbacks to any web application (nice to have)'. The pub/sub event/observer metaphor they have uses callbacks, so you hook specific actions to specific events.

Do auth?

I've had no need, yet, to do any auth for our systems, so I can't speak to it directly. However, if you browse the NodeJS modules you'll notice there are many auth modules available, including LDAP and OAuth, not to mention one module that claims to do "OpenId, Google, OAuth, Twitter, LinkedIn, Yahoo, Readability, Dropbox, Justin.tv, Vimeo, Tumblr, OAuth2, Facebook, GitHub, Instagram, Foursquare, Box.net, LDAP"

违心° 2024-12-01 02:21:19

虽然我还没有尝试过,但我开始在 Pusher 中寻找 Node Knockout 2011 条目。除了 JavaScript 之外,它还支持以下非 js 客户端:

  • Objective-C
  • ActionScript
  • .NET & Silverlight
  • Ruby
  • Arduino

如果可以通过第 3 方进行消息传递,您可以使用他们的 Sandbox 计划(20 个连接和每天最多 100K 消息)免费尝试该服务,看看它是否满足您的需求。 (我对“存在”要求有点不确定,尽管文档中可能涵盖了它。)

Although I haven't tried it yet, I started looking into Pusher for a Node Knockout 2011 entry. In addition to JavaScript, it supports the following non-js clients:

  • Objective-C
  • ActionScript
  • .NET & Silverlight
  • Ruby
  • Arduino

If messaging via a 3rd party is a possibility, you can try the service for free using their Sandbox plan (20 connections & upto 100K messages/day) and see if it meets your needs. (I'm a little uncertain about the "presence" requirement, though it may be covered in the docs.)

旧梦荧光笔 2024-12-01 02:21:19

我推荐使用 node.js 它有很多用于各种东西的库。实时消息传递的一个库是 now.js。我对此没有太多经验,但已经尝试过了,我想说它效果很好并且具有您所说的所需的一切。

I recoment using node.js which has a lot of libraries for various things. One library for real time messaging is now.js. I don't have a lot of experience with this but have tried it and I would say it worked well and has everything you said you need.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文