简体   繁体   English

更改 Firebase 实时数据库乒乓时间

[英]Change Firebase real time database ping pong time

a query related to firebase presence app using javascript sdk. I have seen that there is 60 seconds buffer after the inte.net is disconnected after which the entries are removed from the firebase real tim edatabase.使用 javascript sdk 与 firebase Presence 应用程序相关的查询。我看到在 inte.net 断开连接后有 60 秒的缓冲区,之后条目从 firebase 实时数据库中删除。 Is it possible to configure this time from 60 seconds to lets say 30 seconds?是否可以将这个时间从 60 秒配置为 30 秒? . . I basically want the entries to be removed from the presence as soon as the inte.net is disconnected.我基本上希望在断开 inte.net 后立即删除这些条目。 If not immediately then at least sooner than a minute alteast.Does anybody have any idea on this?如果不是立即,那么至少要提前一分钟。有人对此有任何想法吗?

There are two ways an onDisconnect handler can be triggered on the Firebase servers:在 Firebase 服务器上可以通过两种方式触发onDisconnect处理程序:

  • A clean disconnect is when the client has time to inform the server that it is about to disconnect, and in that case the server executes the onDisconnect handlers immediately.干净断开连接是指客户端有时间通知服务器它即将断开连接,在这种情况下,服务器会立即执行onDisconnect处理程序。
  • A dirty disconnect is when the client disconnects without informing the server.脏断开是指客户端在未通知服务器的情况下断开连接。 In this case the server detects that the client is gone when the socket from that client times out, and then it executes the onDisconnect handlers.在这种情况下,当来自客户端的套接字超时时,服务器会检测到客户端已离开,然后执行onDisconnect处理程序。

Detecting the dirty disconnects takes some times (upwards to a few minutes) and there's no way for you to configure it.检测脏断开连接需要一些时间(最多几分钟)并且您无法配置它。


If you want more granular presence detection, the common approach is to periodically write a timestamp into the database from the client.如果您想要更细粒度的存在检测,常见的方法是定期从客户端将时间戳写入数据库。 This indicates when the client was last active, and can be used by the other clients to then indicate the liveliness of that user/client.这表明客户端最后一次活动的时间,其他客户端可以使用它来指示该用户/客户端的活跃度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM