I'm using Faye for dispatching messages and it works well. But I want to retrieve the active connections for a given channel, and things behave a bit differently: See "list active subscribers on a channel".
I want to show the list of current users chatting in a room. I tried to do this by intercepting the /meta/subscribe
channel via extensions but I'm not quite sure how to send data like the username to the server.
An intercepted message to /meta/subscribe
looks like this:
{"channel"=>"/meta/subscribe", "clientId"=>"50k233b4smw8z7ux3npas1lva", "subscription"=>"/comments/new", "id"=>"2"}
It'd be nice to send "username" => "foo"
.
Monitoring is interesting too, but again, it looks like I can't send any specific data on-subscribe.
Does anyone have experience with these kind of issues?
You can attach data using a client-side extension:
client.addExtension({
outgoing: function(message, callback) {
if (message.channel === '/meta/subscribe') {
message.ext = message.ext || {};
message.ext.username = 'username';
}
callback(message);
}
});
This data will then be visible to your server-side extension. However, before you implement that, read this thread: https://groups.google.com/group/faye-users/msg/53ff678bcb726fc5
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With