Closed andoriyu closed 10 years ago
Hi, just like in Rails, each controller action is specific to the client that requested it. So inside that action anything you send will only go to that client.
Tubesock is not a pub/sub library, it's just the websocket + rails part.
Here's an example of using postgresql's LISTEN/NOTIFY:
http://ngauthier.com/2013/02/rails-4-sse-notify-listen.html
And here's an example of using redis for pub/sub with tubesock to make a chat client:
https://github.com/ngauthier/sock-chat
Good luck!
I know what. I just need an ability to send payload to specific client.
Won't your solution use multiple sockets for different channels?
the pub/sub part is separate from the websocket part. In my example, all clients use the same pub/sub channel, so they all speak in the same chat "room". But, say your url was:
/chat/:id
which caused the pub/sub to subscribe to channel :id
. Then anyone on /chat/4
would see each other's messages, but not those on /chat/5
.
It's up to you to decide how to separate pub/sub channels. If you only ever wanted to message one user, make your pub/sub channel something like user-<user id>
.
It's all up to you.
Nick
I'm trying to make my own pub/sub thingy on top of tubesock. Is there a way to send message to specific clients? I don't want to use Faye because of EM dependency.