The server for Deeper Blue, an assistive chess-playing robot. Developed for the System Design Project, a 3rd year course offered at the School of Informatics, University of Edinburgh.
Puts in the server code to enable real time updating of the /play page on the front-end.
How it works
Socket.IO allows for rooms which let you broadcast events to a number of clients at once. The client has to register for the room (register_for_game_updates) and then will receive all updates posted to that room.
We create rooms dynamically for each game ID by the client sending a message of type 'register' to the server with the game ID as the room name. The server will then register the client for that room. When a move is made, the server will emit the game state to the room for the game ID that was updated.
Little bits
The change in Procfile is because flask-socketio requires a library called eventlet and when running this with Gunicorn, you need to specify that. -w 1 limits to only one worker thread since Gunicorn doesn't support any more with eventlet. This shouldn't be a problem for the scope of this project, but in a real system, we may need to use a different web server.
Puts in the server code to enable real time updating of the
/play
page on the front-end.How it works
Socket.IO allows for rooms which let you broadcast events to a number of clients at once. The client has to register for the room (
register_for_game_updates
) and then will receive all updates posted to that room.We create rooms dynamically for each game ID by the client sending a message of type 'register' to the server with the game ID as the room name. The server will then register the client for that room. When a move is made, the server will emit the game state to the room for the game ID that was updated.
Little bits
The change in
Procfile
is becauseflask-socketio
requires a library calledeventlet
and when running this with Gunicorn, you need to specify that.-w 1
limits to only one worker thread since Gunicorn doesn't support any more witheventlet
. This shouldn't be a problem for the scope of this project, but in a real system, we may need to use a different web server.