replaced all tabs with 4 spaces

This commit is contained in:
logsol 2012-07-28 13:26:05 +02:00
parent 5d11540c55
commit 26f3d22db7
30 changed files with 1017 additions and 1011 deletions

View file

@ -1,34 +1,34 @@
define([
"Game/Server/Channel",
"Game/Server/CoordinatorLink"
"Game/Server/Channel",
"Game/Server/CoordinatorLink"
],
function(Channel, CoordinatorLink) {
function ChannelBootstrap(process) {
function ChannelBootstrap(process) {
var coordinatorLink = new CoordinatorLink(process);
var channel = null;
var coordinatorLink = new CoordinatorLink(process);
var channel = null;
process.on('message', function(message) {
process.on('message', function(message) {
switch(message){
case 'CREATE':
channel = new Channel(coordinatorLink);
break;
switch(message){
case 'CREATE':
channel = new Channel(coordinatorLink);
break;
case 'KILL':
channel.destroy();
process.exit(0);
break;
case 'KILL':
channel.destroy();
process.exit(0);
break;
default:
coordinatorLink.receive(message);
break;
}
});
}
default:
coordinatorLink.receive(message);
break;
}
});
}
return ChannelBootstrap;
return ChannelBootstrap;
});

View file

@ -1,15 +1,15 @@
define([
"Game/Client/Networker",
"Lib/Vendor/SocketIO"
"Game/Client/Networker",
"Lib/Vendor/SocketIO"
],
function(Networker, SocketIO) {
function Client(location, options) {
this.socket = SocketIO.connect(location, options);
this.networker = new Networker(this.socket);
}
function Client(location, options) {
this.socket = SocketIO.connect(location, options);
this.networker = new Networker(this.socket);
}
return Client;
return Client;
});

View file

@ -1,71 +1,71 @@
define([
'http',
'node-static'
'http',
'node-static'
],
function(http, nodeStatic) {
function HttpServer(options) {
options.port = options.port || 1234;
options.caching = typeof options.caching != 'undefined' ? options.caching : true;
options.rootDirectory = options.rootDirectory || './';
function HttpServer(options) {
options.port = options.port || 1234;
options.caching = typeof options.caching != 'undefined' ? options.caching : true;
options.rootDirectory = options.rootDirectory || './';
this.server = null;
this.server = null;
this.init(options);
}
this.init(options);
}
HttpServer.prototype.init = function(options) {
var self = this;
HttpServer.prototype.init = function(options) {
var self = this;
var fileServer = new nodeStatic.Server(options.rootDirectory, { cache: options.caching });
var fileServer = new nodeStatic.Server(options.rootDirectory, { cache: options.caching });
this.server = http.createServer(
function(req, res){
req.addListener('end', function () {
switch(true) {
case req.url == '/':
fileServer.serveFile('./static/html/index.html', 200, {}, req, res);
break;
this.server = http.createServer(
function(req, res){
req.addListener('end', function () {
switch(true) {
case req.url == '/':
fileServer.serveFile('./static/html/index.html', 200, {}, req, res);
break;
case req.url == '/client.js':
fileServer.serveFile('./client.js', 200, {}, req, res);
break;
case req.url == '/client.js':
fileServer.serveFile('./client.js', 200, {}, req, res);
break;
case req.url == '/require.js':
fileServer.serveFile('./node_modules/requirejs/require.js', 200, {}, req, res);
break;
case req.url == '/require.js':
fileServer.serveFile('./node_modules/requirejs/require.js', 200, {}, req, res);
break;
case new RegExp(/^\/app/).test(req.url):
fileServer.serve(req, res, function(){
self.handleFileError(res)
});
break;
case new RegExp(/^\/app/).test(req.url):
fileServer.serve(req, res, function(){
self.handleFileError(res)
});
break;
case new RegExp(/^\/static/).test(req.url):
fileServer.serve(req, res, function(){
self.handleFileError(res)
});
break;
case new RegExp(/^\/static/).test(req.url):
fileServer.serve(req, res, function(){
self.handleFileError(res)
});
break;
default:
self.handleFileError(res);
break;
}
});
}
);
this.server.listen(options.port);
}
default:
self.handleFileError(res);
break;
}
});
}
);
this.server.listen(options.port);
}
HttpServer.prototype.getServer = function(){
return this.server;
}
HttpServer.prototype.getServer = function(){
return this.server;
}
HttpServer.prototype.handleFileError = function (res){
res.writeHead(404, {'Content-Type': 'text/html'});
res.end('<h1>404 not ... found</h1>');
}
HttpServer.prototype.handleFileError = function (res){
res.writeHead(404, {'Content-Type': 'text/html'});
res.end('<h1>404 not ... found</h1>');
}
return HttpServer;
return HttpServer;
});

View file

@ -1,16 +1,16 @@
define([
"Bootstrap/HttpServer",
"Bootstrap/Socket",
"Lobby/Coordinator"
"Bootstrap/HttpServer",
"Bootstrap/Socket",
"Lobby/Coordinator"
],
function(HttpServer, Socket, Coordinator) {
function Server(options) {
coordinator = new Coordinator();
httpServer = new HttpServer(options);
this.socket = new Socket(httpServer.getServer(), options, coordinator);
}
function Server(options) {
coordinator = new Coordinator();
httpServer = new HttpServer(options);
this.socket = new Socket(httpServer.getServer(), options, coordinator);
}
return Server;
return Server;
});

View file

@ -1,36 +1,36 @@
define([
'socket.io'
'socket.io'
],
function(io) {
function Socket(server, options, coordinator) {
function Socket(server, options, coordinator) {
options.logLevel = typeof options.logLevel != 'undefined'
? options.logLevel
: 0;
this.coordinator = coordinator;
this.socket = io.listen(server);
this.coordinator = coordinator;
this.socket = io.listen(server);
this.init(options);
}
this.init(options);
}
Socket.prototype.init = function(options){
Socket.prototype.init = function(options){
var self = this;
this.socket.configure('development', function(){
this.set('log level', options.logLevel);
});
var self = this;
this.socket.configure('development', function(){
this.set('log level', options.logLevel);
});
this.socket.on('connection', function(user){
self.onConnection(user);
});
}
this.socket.on('connection', function(user){
self.onConnection(user);
});
}
Socket.prototype.onConnection = function(socketLink){
this.coordinator.createUser(socketLink);
}
Socket.prototype.onConnection = function(socketLink){
this.coordinator.createUser(socketLink);
}
return Socket;
return Socket;
});