Rails 和 Socket.io (node.js) [英] Rails and Socket.io (node.js)

查看:60
本文介绍了Rails 和 Socket.io (node.js)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我打算使用 Rails 应用来提供由 node.js 服务器和 Socket.io 处理的实时数据.

I intend to use a Rails app to serve real-time data processed by a node.js server and Socket.io.

在 Socket.io 网站上,它说:

In the Socket.io website, it says that:

如果您不使用 Node.JS 来提供服务您的文件,请确保设置全局 WEB_SOCKET_SWF_LOCATION 到WebSocketMain.swf 的位置文件.

If you won't leverage Node.JS to serve your files, make sure to set the global WEB_SOCKET_SWF_LOCATION to the location of the WebSocketMain.swf file.

如果我使用 rails 来提供静态文件,这究竟意味着什么?

What does it means exactly if I use rails to serve the static files?

此外,来自常见问题解答:

Also, from the FAQ:

我想自己托管 Socket.IO 客户端:

I want to host the Socket.IO client myself:

如果您不依赖 Node.JS 为 Socket.IO 客户端提供服务JavaScript 文件,请确保您设置WEB_SOCKET_SWF_LOCATION 权限在包含 socket.io.js 之后WebSocketMain.swf 的位置这是 Socket.IO 找到 Flash WebSocket 所需的 .swf 文件所必需的.

If you're not relying on Node.JS serving Socket.IO clientside JavaScript files, make sure you set the WEB_SOCKET_SWF_LOCATION right after including socket.io.js with the location of the WebSocketMain.swf This is required in order for Socket.IO to find the .swf file required for Flash WebSocket.

不过,我不太明白.

谢谢.

推荐答案

WebSocketMain.swf 文件用作基于 Flash 的套接字通信的一部分,这是 WebSocket 传输不可用时的后备解决方案之一.这是一个静态文件,默认情况下由 socket.io 在内部提供服务.但是,如果您打算使用 RoR 应用程序提供此文件,则应设置 WEB_SOCKET_SWF_LOCATION 以便 socket.io 能够找到 WebSocketMain.swf 文件并在备用情况下使用它.

WebSocketMain.swf file is used as part of the Flash based socket communication which is one of the fallback solutions when WebSocket transport is not available. This is a static file and by default it is served internally by socket.io. However if you intend to serve this file with your RoR application, you should set the WEB_SOCKET_SWF_LOCATION in order to socket.io being able to locate the WebSocketMain.swf file and use it in fallback case.

例如,如果您正在运行独立的 socket.io 服务器,它会在端口 8080 上运行,并从那里提供文件.但是,如果您添加在端口 80 上运行的 RoR,并且您还想使用 RoR 提供 socket.io 静态文件,那么您应该指示 socket.io 关于 WebSocketMain.swf 文件的位置,因为 RoR 使用不同的端口或路径服务它.

For example if you are running standalone socket.io server, it is running lets say on port 8080 and is serving files from there. However if you add RoR, which runs on port 80, and you want to serve also socket.io static files with RoR, then you should instruct socket.io about the location of WebSocketMain.swf file since RoR is using different port or path to serve it.

这篇关于Rails 和 Socket.io (node.js)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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