有没有办法在不成为参与者的情况下订阅房间的“participantConnected”事件?
可以使用调用Video.connect
返回的room
来订阅房间的participantConnected
事件,从而执行各种不同的逻辑当新参与者加入房间时。我还可以在不使用 Video.connect
的情况下远程查询房间,以了解当前有多少参与者已连接。但是,我希望能够使用 participantConnected
事件来实时显示是否有人在房间中,而无需实际加入房间。
这可能吗?如果不通过 Video.connect
成为参与者,也不轮询 twilio 的 api,我该如何做到这一点?
最好,我想在 javascript 端执行此操作,但如果必须的话,我可以在服务器端使用 twilio 的 api 包装器库。我只是希望当有人进入或离开房间时客户能以某种方式收到通知,这样我就可以实时显示房间是否是空的。
One can use the room
returned from calling Video.connect
to subscribe to a room's participantConnected
event, so that all kinds of different logic can be executed when a new participant joins a room. I can also query rooms remotely without Video.connect
to see how many participants are currently connected. However, I would like be able to use the participantConnected
event to display in real time if someone is in a room, without actually joining the room.
Is this possible and how would I do that without becoming a participant via Video.connect
and without polling twilio's api?
Preferably, I'd like to do this on the javascript side, but I could use twilio's api wrapper library on the server-side if I had to. I just want the client to get notified somehow when someone enters or leaves a room so I can display whether the room is empty in real time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为了使用客户端 SDK 接收这些事件,您需要加入房间,因为您需要连接到房间才能从房间接收事件。
不过,您可以订阅房间的状态回调 webhooks。房间发出的许多事件都可以作为 webhook 接收,例如
room-created
、room-end
,以及,正如您所要求的,<代码>参与者连接。您可以在 使用 REST API 创建房间,您可以看到 作为 webhook 请求的一部分发送的所有参数。
In order to receive those events with the client SDK, you would need to join the room as you would need a connection to it in order to receive events from it.
You can, however, subscribe to status callback webhooks for rooms. There are lots of events that a room emits that can be received as webhooks, such as
room-created
,room-ended
, and, as you've asked for,participant-connected
.You can set the
statusCallback
when you create a room with the REST API and you can see all the parameters that are sent as part of the webhook request here.