简单的Python房间聊天服务器
我正在尝试编写一个简单的聊天服务器,它将命令从 ajax 发送到 fsockopen 到守护进程。守护进程如果命令是listen,将把请求保存在一个数组中,并指定它所分配的房间。然后,当命令作为 msg 传入时,它会将该消息发送给该房间的侦听阵列列表中的每个人。我可以获得一些很好的教程或示例来说明这是如何工作的吗?
谢谢
- 在发布第一个答案后添加 -
以帮助任何进一步的答案。我正在使用 jquery ajax getjson 调用一个脚本,其中 php -> fsockopen 到守护进程。我目前有一个 php 守护进程的类似功能副本,但我认为如果用 python 编写,它会更适合。另外,我对套接字技术仍然相当陌生,并且仍在尝试理解流程。所以彗星解。
I am trying to write a simple chat server which sends commands from ajax to fsockopen to the daemon. The daemon if command is listen will hold the request in a array with what room it has assigned. Then when an command comes in as msg it sends that message out to everyone who is in the listening array list for that room. Can I get some good tutorials or examples of how this would work?
Thanks
-- Added after the first answer posted --
To help any further answers. I am using jquery ajax getjson call to a script which php -> fsockopen to the daemon. I currently have a simifunctional copy of the daemon in php but think this is better suited if written in python. Also, I am still fairly new to socket tech and am still trying to understand the flow. So comet solution.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
App Engine Channel API 可能可以实现您想要的功能:http://code. google.com/appengine/docs/python/channel/overview.html
如果您不想在 App Engine 上运行,“Comet”是一个更通用的搜索术语。基本上,您需要某种服务器端推送,必须使用各种 hack 来伪造(直到 websockets 最终准备好)。
The App Engine Channel API probably does what you want: http://code.google.com/appengine/docs/python/channel/overview.html
"Comet" is the more general term to search for if you don't want to run on App Engine. Basically you need some kind of server-side push, which (until websockets is finally ready) must be faked using a variety of hacks.