mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-09-09 11:14:19 +08:00
Code cleanup
This commit is contained in:
@@ -21,7 +21,7 @@ function GarageServer (socketio, options) {
|
||||
|
||||
GarageServer.prototype.registerSocketEvents = function (options) {
|
||||
var self = this;
|
||||
|
||||
|
||||
self.io.of('/garageserver.io').on('connection', function (socket) {
|
||||
if (options.logging) {
|
||||
console.log('garageserver.io:: socket ' + socket.id + ' connection');
|
||||
@@ -68,18 +68,18 @@ GarageServer.prototype.onPlayerDisconnect = function (socket, options) {
|
||||
|
||||
GarageServer.prototype.onPlayerInput = function (socket, input, options) {
|
||||
this.game.addPlayerInput(socket, input);
|
||||
if(options.onPlayerInput) {
|
||||
if (options.onPlayerInput) {
|
||||
options.onPlayerInput(socket, input);
|
||||
}
|
||||
};
|
||||
|
||||
GarageServer.prototype.onPing = function(socket, data, options) {
|
||||
GarageServer.prototype.onPing = function (socket, data, options) {
|
||||
socket.emit('ping', data);
|
||||
if (options.onPing) {
|
||||
options.onPing(socket, data);
|
||||
}
|
||||
};
|
||||
|
||||
exports.createGarageServer = function (io, options){
|
||||
return new GarageServer(io, options);
|
||||
exports.createGarageServer = function (io, options) {
|
||||
return new GarageServer(io, options);
|
||||
};
|
||||
@@ -1,4 +1,4 @@
|
||||
function GarageServerGame (options) {
|
||||
function GarageServerGame(options) {
|
||||
var self = this;
|
||||
|
||||
this.players = [];
|
||||
@@ -8,7 +8,7 @@ function GarageServerGame (options) {
|
||||
this.playersIntervalId = setInterval(function () { self.updatePlayers(options); }, options.playersInterval ? options.playersInterval : 45);
|
||||
}
|
||||
|
||||
GarageServerGame.prototype.updatePlayers = function () {
|
||||
GarageServerGame.prototype.updatePlayers = function (options) {
|
||||
var currentTime = new Date().getTime();
|
||||
for (var i = 0; i < this.players.length; i ++) {
|
||||
//TODO: Retink efficiency
|
||||
@@ -17,7 +17,7 @@ GarageServerGame.prototype.updatePlayers = function () {
|
||||
}
|
||||
};
|
||||
|
||||
GarageServerGame.prototype.updatePhysics = function () {
|
||||
GarageServerGame.prototype.updatePhysics = function (options) {
|
||||
for (var i = 0; i < this.players.length; i ++) {
|
||||
if (this.players[i].inputs.length > 0) {
|
||||
if (this.options.onUpdatePhysics) {
|
||||
|
||||
Reference in New Issue
Block a user