matchmaking works

This commit is contained in:
2025-11-28 13:41:35 +05:30
parent 4d6511505a
commit 9916939f29
2 changed files with 69 additions and 157 deletions

View File

@@ -4,7 +4,6 @@ import Board from "./Board";
export default function TicTacToe() {
const [username, setUsername] = useState("");
const [matchId, setMatchId] = useState("");
const [board, setBoard] = useState<string[][]>([
["", "", ""],
@@ -17,10 +16,9 @@ export default function TicTacToe() {
const {
loginOrRegister,
joinMatchmaker,
joinMatch,
onMatchData,
onMatchmakerMatched,
sendMatchData,
matchId,
} = useNakama();
// ------------------------------------------
@@ -41,15 +39,6 @@ export default function TicTacToe() {
setWinner(state.winner || null);
}
});
onMatchmakerMatched(async (matched) => {
console.log("Matched:", matched);
const fullMatchId = matched.match_id;
setMatchId(fullMatchId);
await joinMatch(fullMatchId);
})
}
// ------------------------------------------