向 Node.js 服务器端代码发送参数
我正在使用 node.js 和 Faye 来实现彗星解决方案。现在,我有 Node.js 服务器文件的代码,用于在通道上发布数据。但是,我需要将通道名称作为参数发送到 node.js 服务器端代码,然后服务器在该特定通道上发布数据。
我该怎么做?任何想法将不胜感激
谢谢
I am using node.js with Faye for implementing a comet solution. Right now,i have the code for node.js server file to publish data on a channel. But, I have a need where i need to send the channel name to the node.js server side code as an argument and the server then publishes data on that particular channel.
How can i do this ? Any ideas will be appreciated
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经知道怎么做了。您必须发送这样的 HTTP 请求并将其发送到 Faye 服务器
{"channel":"/the/channel","data":{"the":"message"}}
这将在 /the 中发布消息/channel
也感谢 Alfred 的回复
I have found out how to do it. You have to send a HTTP request like this and send it to the Faye server
{"channel":"/the/channel","data":{"the":"message"}}
This will publish the message in /the/channel
Thanks to Alfred for his response as well
这并不完全是您问题的答案,但我仍然建议您查看 socket.io。 Socket.io 的开发更加积极(现在),并且也有 rooms(版本 0.7.x)概念。例如,请参见下图。
This is not precisly the answer to your question, but I would still advice you to check out socket.io. Socket.io is more actively developed (right now) and also has a rooms(version 0.7.x) concept. See image below for example.