我使用 Faye 来发送消息,效果很好。但我想检索给定通道的活动连接,并且事情的行为有点不同:请参阅“列出频道上的活跃订阅者”。
我想显示当前在房间中聊天的用户的列表。我尝试通过 extensions< 拦截 /meta/subscribe
通道来做到这一点/a> 但我不太确定如何将用户名等数据发送到服务器。
截获到 /meta/subscribe
的消息如下所示:
{"channel"=>"/meta/subscribe", "clientId"=>"50k233b4smw8z7ux3npas1lva", "subscription"=>"/comments/new", "id"=>"2"}
It'd be Nice to send "username" =>; “foo”。
监控也很有趣,但同样,看起来我无法发送任何特定数据订阅。
有人有处理此类问题的经验吗?
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?
发布评论
评论(2)
您可以使用客户端扩展附加数据:
然后该数据将对您的服务器端扩展可见。不过,在实施之前,请阅读以下帖子:https://groups.google.com/group/faye -用户/msg/53ff678bcb726fc5
You can attach data using a client-side extension:
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
您是否考虑过创建一个频道来定期发布用户当前订阅的频道?您可以将其视为带有附加状态信息(例如他们可能订阅的用户和频道)的心跳/ping。
Have you considered creating a channel for periodically publishing which channel a user is currently subscribed to? You can think of it like a heartbeat/ping with additional status information such as which user and channel they may be subscribed to.