[英]How can I reliably get the timestamp of when a particular participant leaves(and joins) a room in twilio?
I am building a video chat app using twilio's programmatic video api. 我正在使用twilio的程序化视频API构建视频聊天应用程序。 And would like to know how many minutes a particular participant is connected in a room.
并想知道特定参与者在一个房间中连接了多少分钟。
I am currently listening to the roomJoined and room.on('disconnected') events to do ajax requests and update the timestamp on the server using a Date.Now(). 我目前正在监听roomJoined和room.on('disconnected')事件,以执行ajax请求并使用Date.Now()更新服务器上的时间戳。 But when the user closes the browser window in some cases, the request attached to the disconnected event wont fire as the javascript is removed from the dom before that code is executed.
但是在某些情况下,当用户关闭浏览器窗口时,附加到断开连接事件的请求不会触发,因为在执行该代码之前已从dom中删除了javascript。
Is there a reliable way to get this information? 是否有可靠的方法来获取此信息?
Twilio developer evangelist here. Twilio开发人员布道者在这里。
Good news, you can now create rooms using the REST API and setup to receive status callback webhooks from those rooms. 好消息,您现在可以使用REST API创建会议室并进行设置,以接收来自这些会议室的状态回调Webhook 。 The documentation for status callbacks are here , but the important callback you want is the
participant-disconnected
. 状态回调的文档在这里 ,但是您想要的重要回调是
participant-disconnected
。
This particular event comes with a parameter that others do not. 此特定事件带有其他人没有的参数。 The
ParticipantDuration
, which is how long that participant was connected. ParticipantDuration
,即参与者连接的时间。
Let me know if that helps. 让我知道是否有帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.