mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-07-26 13:07:18 +08:00
Progress: Server Loops
This commit is contained in:
@@ -2,21 +2,21 @@ var garageServerGame = require('./garageservergame');
|
||||
|
||||
function GarageServer (socketio, options) {
|
||||
this.io = socketio;
|
||||
this.registerSocketEvents(this.io);
|
||||
this.registerSocketEvents(options);
|
||||
this.game = new garageServerGame.createGame(options);
|
||||
}
|
||||
|
||||
GarageServer.prototype.registerSocketEvents = function () {
|
||||
GarageServer.prototype.registerSocketEvents = function (options) {
|
||||
this.io.of('/garageserver.io').on('connection', function (socket) {
|
||||
this.onPlayerConnect(socket);
|
||||
this.onPlayerConnect(socket, options.onConnection);
|
||||
}.bind(this));
|
||||
|
||||
this.io.of('/garageserver.io').on('disconnect', function (socket) {
|
||||
this.onPlayerDisconnect(socket);
|
||||
this.onPlayerDisconnect(socket, options.onDisconnect);
|
||||
}.bind(this));
|
||||
|
||||
this.io.of('/garageserver.io').on('input', function (socket) {
|
||||
this.onPlayerInput(socket);
|
||||
this.onPlayerInput(socket, options.onInput);
|
||||
}.bind(this));
|
||||
};
|
||||
|
||||
|
||||
@@ -1,8 +1,14 @@
|
||||
function GarageServerGame (options) {
|
||||
|
||||
|
||||
this.physicsIntervalId = setInterval(this.updatePhysics, options.physicsInterval ? options.physicsInterval : 15);
|
||||
this.playersIntervalId = setInterval(this.updatePlayers, options.playersInterval ? options.playersInterval : 45);
|
||||
}
|
||||
|
||||
GarageServerGame.prototype.update = function () {
|
||||
GarageServerGame.prototype.updatePlayers = function () {
|
||||
|
||||
};
|
||||
|
||||
GarageServerGame.prototype.updatePhysics = function () {
|
||||
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user