actioncable 是否支持从离线客户端恢复?

Does actioncable support resuming from an offline client?

我有一个 javascript SPA 应用程序需要支持用户短时间离线。我正在考虑使用 actioncable 来广播客户端可能不知道的更改。

如果一个 websocket 连接丢失了一小段时间,然后重新连接:客户端会收到离线时广播的消息吗?

是的。当客户端访问 Internet 时,Action cable 将触发重新连接。

您可以通过在服务器和客户端上记录连接,然后使客户端脱机并重新连接来自行测试。

希望这对您有所帮助。

来自guide

Broadcastings are purely an online queue and time dependent. If a consumer is not streaming (subscribed to a given channel), they'll not get the broadcast should they connect later.

所以不,客户端将不会收到离线时发送的消息。