ryanb / private_pub

Handle pub/sub messaging through private channels in Rails using Faye.
MIT License
864 stars 228 forks source link

Creating private channels #107

Open RickS1 opened 9 years ago

RickS1 commented 9 years ago

Hi!

I'm using this incredible gem to implement a chat application. It's been working great, according to what the RailsCast shows; however, I'm wondering how can I create multiple channels so I can have private sessions? I haven't found any examples of that and, although "/messages/new" works perfectly, it broadcasts the conversation to all chat windows (and this is unwanted).

Thanks in advance! And sorry if my question seems dumb.

spacewaffle commented 9 years ago

You'll want to dynamically change the url for each channel you want to support. For example,

subscribe_to "/messages/1" These subscribers will only get messages from channel 1.

subscribe_to "/messages/2" These subscribers will only get messages from channel 2.

RickS1 commented 9 years ago

And does the wildcard () also applies with this gem? I've been reading from Faye documentation that it is useful to subscribe to any available channel (for example, subscribe_to "messages/" will subscribe the user to every channel). This doubt is because I need to implement a one-to-many chat like application, and obviously one specific user needs to be subscribed to every channel to answer each and any of the conversations.

Thanks in advance!