I'm developing a game using AWS Amplify. The game state will be stored in DynamoDB tables and will be queried and modified with GraphQL. There isn't a pressing need for realtime or low-latency communication; However, I need to detect when a player joins or disconnects from a game. What's the best mechanism for implementing this?

What I had in mind was an event that fires when a WebSocket connection is established or broken. The best I could glean from the Amplify docs was using [PubSub with AWS IoT](https://docs.amplify.aws/lib/pubsub/getting-started/q/platform/js), but I don't know if this will work. If possible, I would like to avoid incurring additional API costs.

I already implemented a version of this where the client updates a `lastSeen` field in the database every 30 seconds or so but it felt pretty janky.