ross wrote:
pio wrote:
The backend server speaks a simple JSON-based network protocol, allowing creation of non-web-based front ends as well.
Is the protocol documented somewhere? (Even a pointer to the code that implements it would be nice.) I was working on a similar GPL's go server before health problems destroyed all my free time, but it would be nice to take a look at someone else's protocol to compare--if I ever get back on my feet and can restart my project, maybe I can make my server speak a compatible protocol and borrow the front-end code from OWGS.
The protocol is still pretty fluid, this is all very much in-progress still. Here's a super quick rundown. All commands are JSON arrays. Commands are delimited by newlines ("\r\n"), so any newlines in the command must be quoted. The number of parameters varies per command. If you sign up on the server, and enable "Debug" in your profile, then play a game against GNUGo, you'll see the raw protocol with time stamps in a textarea at the bottom of the screen. There's also a box you can use to submit raw JSON strings to the server to tinker around.
SESS - Client sends this to the server to identify itself by a session ID (for web clients that are already logged in)
AUTH - Client sends this along with username, password to identify itself (for non-web clients - currently just GTP bot)
ERROR - Server transmits this to inform the client that the previous command had an error. Argument is an error text string.
PCHT - "Part chat", send by a client to leave a chat channel, sent by the server to clients to inform them someone left the channel.
GAME - Client sends this to create a game, along with various game parameters (for non-web clients)
JOIN - Client sends this to join a game. Server sends this to notify others on the game that someone has joined.
CMNT - Client sends this to comment on a game, server sends it to send the comment to others
MOVE - Client sends this to make a move, server sends it to notify others of a move. In the client's request is a "parent node" that refers to the SGF node that the move is being made as a child of (supports making moves on variations etc)
SYNC - Server sends this if the client does something which indicates it is not synchronized with the server (like make an illegal move, attempt to NAVI when not allowed)
NODE - Server sends this to a client after they make a move to instruct the client to store a server-side node ID for the SGF node created by the previous move.
TIME - Server sends this to client with various time parameters to update the client's clock.
DEAD - Client sends this to mark stones dead, server sends it to relay client marking stones dead.
BEGN - Client sends this to accept an offer on a pending game, server sends it to relay the acceptance to other game participants.
OFFR - Client sends this to make an offer on a pending game, server sends it to relay the offer to others.
NAVI - Client sends this to seek to a specific node in the game tree, server sends it to relay the move to others.
UNDO - Client sends this to request an undo, server relays it to others
OKUN - Client sends this to accept an undo request, server relays it
NOUN - Client sends this to reject an undo request, server relays it
RSGN - Client sends this to resign a game, server relays it
SCOR - Client sends this to submit a final score, server relays it.. when both opponents send a matching SCOR the game ends and the submitted score is the final result
PART - Client sends this to join a game, server relays it to others
JCHT - Client sends this to join a chat, server relays it to others
CHAT - Client sends this to chat in a game, server relays it to others.
For the implementation see:
Server:
http://github.com/Tecuya/owgs/blob/master/netserver.py Client:
http://github.com/Tecuya/owgs/blob/mast ... tClient.js