+router.post('/spectator', (request, response) => {
+ const game = request.game;
+ var name = request.session.nickname;
+
+ /* If the request includes a name, that overrides the session nickname. */
+ if (request.body.name)
+ name = request.body.name;
+
+ const id = game.add_spectator(name, request.session.id);
+ response.send(JSON.stringify(id));
+});
+
+router.delete('/spectator/:id', (request, response) => {
+ const game = request.game;
+ game.remove_spectator(parseInt(request.params.id));
+ response.send();
+});
+
+router.post('/register', (request, response) => {