There should be a protocol where you can open a websocket and ask to be matched up into a game, then the server will create games for the connections that are waiting in the queue.
For example:
connection1 asks for a match {token: "t1", name: "bob"}
connection2 asks for a match {token: "t2", name: "gob"}
The server sees that it has two pending requests and generates a unique `game_id`
TicTacToe.create_or_join("tictactoe:#{game_id}", %{token: "t1", name: "bob"})
then adds connection1 to the "tictactoe:#{game_id}" channel and sends it a message like {topic: "tictactoe:#{game_id}", role: "X"}
TicTacToe.create_or_join("tictactoe:#{game_id}", %{token: "t2", name: "bob"})
then adds connection2 to the "tictactoe:#{game_id}" channel and sends it a message like {topic: "tictactoe:#{game_id}", role: "O"}
Unanswered questions:
How do you check if a connection is still open? I need to cancel pending requests if a websocket connection drops
How do I add a connection to a phoenix channel on the backend? Normally this happens when the connection sends a {topic: "tictactoe:123", event: "phx_join", ...}, but the game joining will have already happened. Not sure how to handle this.
I started implementing this in the match maker branch, but I'm leaving it to the side for a while because I think creating games against a hosted AI is a more important feature to have ready for UV.rb September.
Think "Tinder for AI games"
There should be a protocol where you can open a websocket and ask to be matched up into a game, then the server will create games for the connections that are waiting in the queue.
For example:
Unanswered questions: