如何建立一个可以在服务器运行期间创建新频道的聊天室?
阅读了很长一段时间有关 node.js 的文章后,我尝试使用 socket.io 编写自己风格的聊天室。 这是链接,但只有一个频道:http://zhonglichat.cnodejs.net/ 这是我的想法: 访问者可以通过输入标题并单击“提交”来创建新频道。 然后他们也可以像访问另一个聊天室一样访问新频道。 而这一切都是在服务器运行时发生的。我浏览了 socket.io 上的指南,似乎很难创建新通道。那么有什么简单的方法可以让我做到这一点吗?
Having read posts about node.js for a long time, I tried to write my own style of chatroom with socket.io .
Here's the link, but only one channel: http://zhonglichat.cnodejs.net/
Here's what I'm thinking about:
Visitors can create new channels by typing title and clicking 'Submit'.
Then they can also visit the new channel just like visiting another chatroom.
And all these happen while the server is running. I went through the guide on socket.io , seems it's hard to create new channels. So is there any simple way via which I can make that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不需要使用最新版本的 Socket.IO 创建通道,重要的是让客户端加入它,在服务器端查看此代码示例(来自 github 存储库):
如您所见,“Justin bieber 粉丝”频道尚未创建,但客户可以加入它。
There's no need to create a channel with the latest version of Socket.IO, the important thing is just to make clients join it, look at this code example on the server side (from the github repo):
As you can see the 'justin bieber fans' channel wasn't created, but clients can join it.