forked from domasx2/banditracer-server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ringomain.js
41 lines (33 loc) · 1006 Bytes
/
ringomain.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
var {Application} = require("stick");
var settings = require('banditracer-client').settings;
var log = require('ringo/logging').getLogger(module.id);
export("app");
var app = Application();
app.configure("mount");
app.mount("/", require("banditracer-client"));
var combatserver=require('./combatserver');
var server;
var cserver;
var start = function() {
var context = server.getDefaultContext();
cserver=new combatserver.CombatServer('ringo');
context.addWebSocket("/combatserver/", function (socket) {
log.info('connection established');
socket.onmessage = function(m) {
var retv=cserver.handle(m, socket);
};
socket.onclose = function() {
log.info('closed', socket);
if(this.player)this.player.disconnect();
};
});
return;
};
var startUp = exports.startUp = function() {
server = require("ringo/httpserver").main(module.id);
start();
};
// Script run from command line
if (require.main === module) {
startUp();
}