Protocol - Zomis/Server GitHub Wiki
Client-Server Protocol
The server is designed with flexibility in mind. The server is meant to be able to handle several different types of games. For example, both Battleship and Ultimate Tic Tac Toe.
Additionally, the server has itself no restriction on how many games a client can play with at once (primarily in order to support computer-controlled opponents, so called "bots" or "AIs").
General
All messages from you to the server needs to be terminated by the line feed character, \n
.
All messages from the server to you will also be terminated by the line feed character, \n
.
Don't forget to flush your sockets!
Login
Send USER xxx username password
The xxx
and password
parts are currently ignored. username
needs to be unique at the moment, otherwise the server will not accept you.
Invite a player
INVT gametype username
This will send an invite to the username username
to play the game type gametype
.
Current available gametypes is: UTTT
and Battleship
Accept Invite:
From server: INVT id gametype username
Send: INVY id
Reject Invite:
From server: INVT id gametype username
Send: INVN id
Game start
From server: NEWG gameid playerIndex
When you receive this, it means that the server now considers you to be playing in the gameid noted by gameid
, as the player index playerIndex
(0 = first player, 1 = second player, and so on).