有没有办法在不成为参与者的情况下订阅房间的“participantConnected”事件?

发布于 2025-01-17 21:05:24 字数 471 浏览 0 评论 0原文

可以使用调用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

抹茶夏天i‖ 2025-01-24 21:05:24

为了使用客户端 SDK 接收这些事件,您需要加入房间,因为您需要连接到房间才能从房间接收事件。

不过,您可以订阅房间的状态回调 webhooks。房间发出的许多事件都可以作为 webhook 接收,例如 room-createdroom-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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文