Implementing chat in Rails

南楼画角 提交于 2019-12-12 01:47:34

问题


I am trying to implement a chat module in my rails application. I looked into this railscast Faye tutorial. More through the tutorial, Ryan mentions about broadcasting the messages but what I want is more like private conversations between the clients instead of broadcasting.

Is it possible to do that through faye? or is there a better way of implementing chat in rails?


回答1:


There is a gem that handles the autentications for you for faye, so users can only listen on channels you subscribe them to. There is also a railscast talking about that gem. https://github.com/ryanb/private_pub




回答2:


I don't know much about Faye, but assuming the principles are the same as with something like pure node.js and websockets, you'd divide the channels that can be subscribed to down into as many chats as there are occurring, then you'd require some sort of authentication before a client can subscribe to that channel, of which there are numerous approaches, as with most authentication systems (e.g. shared secret, username/password, challenge/response etc).




回答3:


I have used Ryan's tutorial on private_pub to achieve an a Gmail like instant messaging feature. It's actually not very complex. See how I achieved it in this tutorial http://goo.gl/l3e8zN



来源:https://stackoverflow.com/questions/10369263/implementing-chat-in-rails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!