ryanb / private_pub

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

unsubscribe missing #45

Open mrbrdo opened 12 years ago

mrbrdo commented 12 years ago

It seems unsubscribe functionality is missing. "sign"-ing twice to the same channel makes duplicate messages.

mrrooijen commented 12 years ago

I second this feature. It would be nice to be able to subscribe and unsubscribe, especially when you're working with full-JS front-end applications, like the ones you write in Backbone, Spine, Ember, Knockout, Knockback, Batman, Sproutcore, etc.

Being able to toggle between subscribe and unsubscribe would be a great addition, even if it means having to set the expiration to never. It should be safe enough when going over an HTTPS protocol I assume.

nir0 commented 12 years ago

a hack:

  :javascript
    if(!$(window).data("connected")){
    #{subscribe_to("/chat/#{@chat.id}").gsub('</script>', '').gsub('<script type="text/javascript">','')}
    $(window).data("connected", true)
    }