🎮 Tic Tac Toe Multiplayer API

Base Socket.IO URL: https://szabfun-backend.onrender.com/tic-tac-toe/socket.io

This API uses Socket.IO for real-time multiplayer Tic-Tac-Toe games.

Connect

Connect to the Socket.IO server using the custom path:

const socket = io("https://szabfun-backend.onrender.com", { path: "/tic-tac-toe/socket.io" });

Socket.IO Events

  • startGame
    Sent by server when a game starts.
    { room: "room-id", symbol: "X" | "O" }
  • waitingForOpponent
    Sent by server if you are waiting for another player.
    { room: "room-id" }
  • roomFull
    Sent by server if the room is full.
    { room: "room-id" }
  • updateBoard
    Sent by server when the opponent makes a move.
    [["X", "", ""], ["", "O", ""], ["", "", ""]]
  • gameOver
    Sent by server when the game ends.
    { winner: "X" | "O" | null }

Client Events

  • joinRoom
    Join a specific room (optional, for custom games):
    socket.emit("joinRoom", "room-id");
  • move
    Send your move to the server:
    socket.emit("move", { room: "room-id", board: [["X", "", ""], ["", "O", ""], ["", "", ""]] });
  • gameOver
    Notify server that the game is over:
    socket.emit("gameOver", { room: "room-id", winner: "X" });

Game Flow

  1. Connect to the server via Socket.IO.
  2. Wait for startGame event to receive your symbol and room.
  3. Send moves using the move event.
  4. Listen for updateBoard and gameOver events.