Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What RESTful API would you use for a turn-based game server?

Tags:

rest

chess

How would you model a turn-based game server as a RESTful API? For example, a chess server, where you could play a game of chess against another client of the same API. You would need some way of requesting and negotiating a game with the other client, and some way of playing the individual moves of the game.

Is this a good candidate for a REST (RESTful) API? Or should this be modelled a different way?

like image 504
Ross Avatar asked Jan 01 '09 22:01

Ross


2 Answers

I don't think REST is a good choice for such an application. The transformations and operations you need to do (make move, view move history, undo, get suggestion, turn notification) do not map neatly to REST's concept of resources. (The difficulties are perhaps more obvious if one considers how a RESTful API for more complicated turn-based games such as Scrabble or Monopoly might look.)

I think any sensible REST API would probably end up being a wrapper around something non-RESTful, such as a stateful protocol that sent portable game notation back and forth.

like image 174
mjs Avatar answered Oct 02 '22 14:10

mjs


One of the developers in planet.jabber is involved in Chesspark, an online chess community. They are using Jabber/XMPP extensively; if I'm not mistaken, these are his posts on the subject.

XMPP is an instant-messaging protocol, roughly based on small XML message exchange. There are libraries for most languages, including Javascript. I'm not sure it will fit your problem, though.

like image 40
alex Avatar answered Oct 02 '22 14:10

alex