A TicTacToe TCP multiplayer server.
- Unlimited 1v1 matches in parallel
- Winner/tie detection
- Disconnect handling
ping
- Expects a
pong
response
- Expects a
match-found:[xo]
, e.g.match-found:x
- Is sent once a match is found
- Contains your sign (
x
oro
)
your-turn
- It's your turn (send a
click
message)
- It's your turn (send a
their-turn
- Your opponent needs to send a
click
message
- Your opponent needs to send a
opponent-disconnected
- Your opponent disconnected
board:000000000
, e.g.board:120000000
- Is sent once the board status changes
- Contains the content of all fields
- Content represented using integers
- 0: empty
- 1: cross
- 2: circle
- Left to right, top to bottom
- In this example the top left field is filled with a cross and the one to the right of it with a circle
- Content represented using integers
winner:000
, e.g.winner:048
- Is sent once you win
- Contains the indices of the winning streak (in the example top-left to bottom-right)
loser:000
, e.g.loser:048
- Is sent once you lose
- Contains the indices of the winning streak (in the example top-left to bottom-right)
tie
- Is sent once all fields are filled without a winner
ping
- Responds with
pong
- Responds with
click:[0-8]
, e.g.click:2
- Only allowed when it is your turn
- Only allowed when the field is empty
- Fill the field with the specified index with your sign
again
- Can be sent once the game is complete
- If both parties send this command, the game will be restarted
- Go 1.17+
git clone https://github.com/juho05/tictactoe-backend.git
cd tictactoe-backend
go build -o tictactoe-backend ./cmd/main.go
./tictactoe-backend
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.
Copyright © 2022 Julian Hofmann