在AWS AppSync中检测状态 [英] Detect Presence in AWS AppSync

查看:74
本文介绍了在AWS AppSync中检测状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个很大程度上依赖于检测用户何时脱机并重新联机的应用程序.我想使用AWS AppSync做到这一点,但似乎无法在文档中找到实现此目的的方法.有没有办法在AppSync中做到这一点?

I am working on an app that relies heavily on detecting when users go offline and go back online. I wanted to do this with AWS AppSync, but I can't seem to find a way to do this in the documentation. Is there a way to do it in AppSync?

推荐答案

感谢您提出问题.当前不支持开箱即用的检测状态,但是您可以根据用例自行构建类似的功能.

Thanks for the question. Detecting presence is not currently support out of the box but you can likely build similar features yourself depending on the use case.

例如,每次新设备尝试打开订阅时,都会在订阅字段上调用解析程序.您可以使用此解析器字段来更新某些数据源,以告知系统的其余部分当前有某些用户已订阅.如果使用DynamoDB之类的工具,则可以使用TTL字段在一定时间后自动删除记录,然后要求用户每N分钟"ping"一次以指定它们仍处于在线状态.

For example, a resolver on a subscription field is invoked every time a new device tries to open a subscription. You can use this resolver field to update some data source to tell the rest of your system that some user is currently subscribed. If using something like DynamoDB, you can use a TTL field to have records automatically removed after a certain amount of time and then require a user to "ping" every N minutes to specify that they are still online.

当应用程序首次将用户注册为在线时,您还可以让您的应用程序调用一个突变,然后在应用程序关闭以将其注册为离线时,让应用程序调用另一个突变.您可以将其与TTL结合使用,以防止在应用崩溃或由于某些原因阻止通话注册为离线时发生陈旧记录.

You could also have your application call a mutation when it first starts to register the user as online, then have the application call another mutation when the app closes to register it as offline. You could combine this with TTLs to prevent stale records in situations where the app crashes or something prevents the call to register as offline.

感谢您的建议,希望对您有所帮助.

Thanks for the suggestion and hope this helps in the meantime.

这篇关于在AWS AppSync中检测状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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