in the tutorials I found the matchmaking is always done with a long-polling lambda request and within the lambda function there is short-polling against the flexmatch-service, to retrieve the state of current player matchmaking.
Since this should not be done in production, I tried to implement it in an event-based way. But how?
In my case the game should run on different devices/platforms like Android/Windows. The matchmaking does not have to be confirmed by the player -also it should be fast, cheap & scalable.
If I don’t want to make short-polling on the player-client (like calling lambda every second, which would be very expensive I guess), I have only 2 options with aws afaik, to get the ip-address+port from flexmatch:
- Long polling with lambda (and an event-based strategy within lambda)
- Using push notification service, to make usage of e.g. SNS (which would be connected to flexmatch)
I liked the 1. way, because it seems to be the simplest solution. But I have no idea how to get data from a queue.
- E.g. I cannot subscribe within lambda-function to SNS. I would still be fine with like a every-second short-polling, but it seems I only have write-access there (yes, you can let lambda functions getting executed by SNS, but this does not help me here)
- Maybe emitting SNS messages to SQS, since I can read SQS within lambda. But I cannot filter SQS, so every waiting player lambda-function would get “all” flex-match messages. Can’t imagine that this would be the right way.
- Then there is also this EVENT-BRIDGE service, but it seems I also cannot not read from it within lambda.
Then there would be only the 2nd solution.
- I could imagine the workflow, like player-client makes a lambda-call, which will start matchmaking and returns the ticket-id. Then the player-client would try to connect to SNS via push notification service and provides the ticket-id as filter for SNS.
But this seems to be very complex, since you need first to catch a token (for app+device) to establish a connection…
Is there maybe another way? Or how was it done by others? I would be really thankful for any help!