0

I'm trying to implement kind of a Facebook chat using the private_pub gem and I'm having the following problem:

let's say two people are logged in the application user1 and user2. user1 sends a message to user2; but user2 won't receive that message unless he's subscribed to the conversation channel which only happens when user2 wants to send a message to user1 (opens the chat window).

What would be the best way to subscribe user2 to the channel at the time user1 sends the message (it's that even possible?) if this is not possible then what would be the best way to accomplish this. One thing I can think of right now is to subscribe user2 to the channel whenever the pages loads but I guess that won't be good if we have too many users that can talk with each other.

Thanks for the help!

Daniel89
  • 23
  • 7

1 Answers1

0

I think you are trying to create a facebook like chat system . For that I would recommend you to follow this article .

http://josephndungu.com/tutorials/gmail-like-chat-application-in-ruby-on-rails

This is a great example of using private_pub gem and it also explain how can you create a conversation system like facebook.

Nilay Singh
  • 2,201
  • 6
  • 31
  • 61