+router.post('/move', (request, response) => {
+ const game = request.game;
+ const square = request.body.square;
+
+ const legal = game.add_move(square);
+
+ /* Inform this client whether the move was legal. */
+ response.send(JSON.stringify(legal));
+
+ /* And only if legal, inform all clients. */
+ if (! legal)
+ return;
+
+ game.broadcast_move(square);
+});
+
+router.get('/events', (request, response) => {
+ const game = request.game;
+
+ game.handle_events(request, response);
+});
+
+exports.router = router;
+exports.name = engine_name;
+exports.Game = TicTacToe;