如何使用 ruby Gserver 构建基于网络的聊天系统
我正在尝试构建一个基于网络的聊天系统,并且我将使用 ruby gserver。我看过 这个示例 。然而我的问题是,当我从网络获取用户输入时,在控制器中我有用户输入。现在客户端如何连接到服务器以将用户输入值传递到服务器。
服务器获得该值后将填充数据库。因此客户端将从数据库执行所有读取操作。不过我想知道客户端如何连接到服务器。这是一个简单的问题,但我无法弄清楚。
I am trying to build a web based chat system and I am going to user ruby gserver. I have looked at this example . However my question is when I get the user input from the web and in the controller I have the user input. Now how does client connect to server to pass this user input value to the server.
The server after getting the value will populate a database. So the client will do all read operations from database. However I was wondering how will client connect to server. It is a simple question but I could not figure it out.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
现在,我正在做出一些巨大的假设,因为你的问题非常模糊。
假设 1:您正在运行几乎未修改的聊天服务器
假设 2:您在同一主机上运行 Web 服务和聊天服务器
在这种情况下,您可以使用套接字库连接到聊天服务器,并以这种方式向其发送数据。
这会将“foo”发送到聊天服务器,然后关闭连接
Now, I'm making some massive assumptions, because your question is as vague as hell.
Assumption 1: You are running the chatserver pretty much unmodified
Assumption 2: You are running the web service and the chat server on the same host
In that case, you can connect to the chat server using the socket libs, and send it data that way.
This will send "foo" to the chat server, and then close the connection