Implementing chat in Rails

2019-09-14 23:07发布

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?

3条回答
手持菜刀,她持情操
2楼-- · 2019-09-14 23:18

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

查看更多
劳资没心,怎么记你
3楼-- · 2019-09-14 23:25

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).

查看更多
神经病院院长
4楼-- · 2019-09-14 23:35

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

查看更多
登录 后发表回答