重新连接后推送器不接收事件 [英] Pusher doesn't receive events after reconnect

查看:54
本文介绍了重新连接后推送器不接收事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建具有实时更新功能的浏览器应用程序.

I am building browser application with real-time updates.

应用程序允许与其他人一起在线阅读和编辑电子表格.

Application allows to read and edit spreadsheet together with other people online.

但是,有些人的 Internet 连接不佳,可能会出现断开连接的情况.

However, some people have poor Internet connection and disconnects may occur.

我希望应用程序能够在 Internet 重新连接后更新到最新数据.

I want application to be able to update to the latest data after Internet reconnection.

目前 Pusher 和应用程序是这样工作的:

  1. Pusher 连接到服务器并接收事件.
  2. 其他人在电子表格中进行更改.
  3. 应用程序从 Pusher 接收这些更改,并能够将它们反映在电子表格上.
  4. 互联网有时会消失.
  5. Pusher 检测到这一点并自动尝试重新连接.
  6. 其他人在电子表格中进行更改.
  7. 应用程序无法接收这些更改,因为没有互联网连接.
  8. 一段时间后,例如 5 分钟,互联网连接似乎正常.
  9. 现在 Pusher 成功重新连接到服务器.
  10. 但是,Pusher 不会接收没有互联网连接期间的事件(列表项 #6).
  11. 其他人做出改变.
  12. Pusher 接收事件并且应用程序能够处理它们.

所以我的问题是:Pusher 在自动重新连接后没有收到其他人在 Internet 断开连接期间触发的事件.

So my problem is: Pusher doesn't receive events after automatic reconnect which were triggered by other people during Internet disconnection.

我正在使用默认的 Pusher 配置、私人频道、最新的稳定版本,并且不做任何魔术.

I am using default Pusher configuration, private channel, latest stable version and don't do any magic.

推荐答案

Pusher 当前不提供此功能.要自己实现这一点,您必须为每条增加值的消息发送一个数字 ID.您还需要在数据库中存储所有已发送消息的缓存.客户可以跟踪他们收到的最后一个 ID.断开连接并重新连接后,他们可以向您的服务器发送请求,要求所有大于他们收到的最后一条消息 ID 的消息.您的服务器应使用与您数据库中的查询匹配的消息进行响应.

Pusher does not currently provide this functionality. To implement this yourself you would have to send a numeric ID with each message that increases in value. You would also need to store a cache of all sent messages in a database. Clients can keep track of the last ID they received. After disconnecting and reconnecting, they can send a request to your server asking for all messages greater than the last message ID they received. Your server should respond with messages matching that query in your database.

这篇关于重新连接后推送器不接收事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆