ryanb / private_pub

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

Ajax get request on subscribe #34

Closed wuiscmc closed 12 years ago

wuiscmc commented 12 years ago

Hey everybody,

I don't know if this is the right place to post this but I was wondering the reason of the following behaviour:

In model.rb : publish_to "/channel", id: self.id . in application.js, the PrivatePub.subscribe performs a get request to a controller passing id. It the end the controller renders the action but it does it as many times as clients are subscribed.

Why is this happening?

wuiscmc commented 12 years ago

ok, I figured out what was happening.

In my controller, I was rendering a JavaScript partial which was publishing to another channel the results. The problem was that both of them were overlapping and publishing the same thing to different channels. Therefore, the browsers were rendering n clients times the results.