Groovy for Domain-specific Languages - Second Edition

(nextflipdebug2) #1

Integrating It All


[ 342 ]

This starts the server on localhost port 8080 so we can use curl to get a response to
the game start event, as follows (alternatively, just enter the URL into a browser):


$ curl http://localhost:8080/tictactoe/game_start
{
"grid": [
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" ",
" "
],
"page": "players",
"players": [
{
"name": "Next Free Space Player",
"playerClass": "NextFreeSpacePlayer"
},
{
"name": "Random Blocking Player",
"playerClass": "RandomBlockingPlayer"
},
{
"name": "Random Player",
"playerClass": "RandomPlayer"
}
],
"sessionId": "81a6db09-fb78-485f-8cca-3b5e69e5a0df",
}


Response is cleaned up and formatted. If you are running
on Mac OS X or Linux and have Python installed, try piping
output to:
python –mjson.tool

http://www.ebook3000.com
Free download pdf