DanKnox/websocket-rails — pull request #10 by MhdSyrwan (2012-07-14 20:01:22+00:00)
Title: Event state callbacks

here's my view in private channel implementation
let's suppose that or channel is "posts"

in any initialization place in the web application code we should write

```
WebsocketRails[:posts].make_private
```

then at the client we write :

```
dispatcher = new WebSocketRails('localhost:3000/websocket'); // create dispatcher like normal
dispatcher.on_open = function() {
var channel = dispatcher.subscribe_private('posts');
channel.bind('posted', publishPost); // just like binding to global events on the dispatcher
}
```

and in the events.rb

```
namespace :websocket_rails do
subscribe :subscribe_private, :to => EventsController, :with_method => :private_subscribe
end
```

and in EventsController
```
def private_subscribe
if (my_conditions)
accept_channel
else
deny_channel
end
```