add random match-making logic

This commit is contained in:
2026-09-21 22:40:35 +03:00
parent 30cf8c7215
commit 7db58e42ab
7 changed files with 163 additions and 1 deletions
@@ -0,0 +1,21 @@
class Api::MatchmakingController < ApplicationController
def create
result = MatchmakingService.find_match(current_user.id)
if result
render json: {
match_id: result[:match_id],
game_token: result[:game_token],
game_server: result[:game_server],
players: result[:players]
}
else
render json: { error: "No opponent found. Try again." }, status: :request_timeout
end
end
def destroy
MatchmakingService.cancel(current_user.id)
render json: { message: "Matchmaking cancelled" }
end
end