-
Notifications
You must be signed in to change notification settings - Fork 8
/
server.js
26 lines (21 loc) · 896 Bytes
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
/*global require,console,__dirname*/
/* jshint node:true */
'use strict';
var Express = require('express.io');
var BodyParser = require('body-parser');
var Game = require('./lib/game');
var both = require('./lib/both');
var cors = require('cors');
var httpdump = require('./lib/utils').httpdump;
var State = Game.state();
var App = new Express();
App.use(BodyParser.urlencoded({ extended: true }));
App.use(Express.static(__dirname + '/static'));
App.use(httpdump);
App.use(cors());
App.http().io();
App.post('/register/', function (req, res) { Game.register(State, req, res, App.io); });
App.post('/move/', function (req, res) { Game.move(State, req, res, App.io); });
App.get('/reset/', function (req, res) { State = Game.state(); both.clear(); res.send('reset ok'); console.log('reset');});
App.listen(3000);
console.log('Server started on localhost:3000');