-
Notifications
You must be signed in to change notification settings - Fork 5
/
server.js
54 lines (40 loc) · 1.49 KB
/
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
startup = require('./startup');
DB_CONFIG_FILE = "config/db.json"
KEYS_CONFIG_FILE = "config/keys.json"
ENV = startup.get_env();
http = require('http'),
path = require('path'),
io = require('socket.io'),
fs = require('fs');
paperboy = require('paperboy');
Services = require('./src/server/services').Services;
LandscapeHandler = require('./src/server/landscapehandler').LandscapeHandler;
var serviceHandler = new Services();
var landscapeHandler = new LandscapeHandler();
ROOT = path.dirname(__filename) + '/site/app/';
server = http.createServer(function(req, res){
if(serviceHandler.handle(req, res)) return;
if(landscapeHandler.handle(req, res)) return;
paperboy
.deliver(ROOT, req, res)
.otherwise(function(){
res.writeHead(404, "Content-Type: text/plain");
res.write("Not found and all that");
res.end();
});
});
server.listen(process.env.PORT || 8000 );
var Controller = require('./src/core/controller').Controller;
var ServerApp = require('./src/server/application').ServerApp;
var ServerCommunication = require('./src/server/communication').ServerCommunication;
var LandscapeController = require('./src/entities/landscapecontroller').LandscapeController;
var app = new ServerApp();
var controller = new Controller(app.scene);
var game = new ServerCommunication(app, server);
var landscape = new LandscapeController.Create(app);
app.resources.onAllAssetsLoaded(function(){
app.start();
setInterval(function(){
game.synchronise();
}, 1000);
});