mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-08-04 12:33:42 +08:00
Reduced output traffic based on inputs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
$(function () {
|
||||
GarageServerIO.connectToGarageServer('http://garageserver_io.jbillmann.c9.io', { logging: false });
|
||||
GarageServerIO.connectToGarageServer('http://garageserver_io.jbillmann.c9.io', { logging: true });
|
||||
|
||||
var gameCanvas = document.getElementById('gameCanvas'),
|
||||
|
||||
|
||||
@@ -11,9 +11,10 @@ function GarageServerGame(options) {
|
||||
GarageServerGame.prototype.updatePlayers = function (options) {
|
||||
var currentTime = new Date().getTime();
|
||||
for (var i = 0; i < this.players.length; i ++) {
|
||||
//TODO: Retink efficiency
|
||||
this.players[i].client.emit('update', { id: this.players[i].client.id, state: this.players[i].state, seq: this.players[i].sequence, timestamp: currentTime });
|
||||
this.players[i].client.broadcast.emit('update', { id: this.players[i].client.id, state: this.players[i].state, seq: this.players[i].sequence, timestamp: currentTime });
|
||||
if(this.players[i].inputs.length > 0) {
|
||||
this.players[i].client.emit('update', { id: this.players[i].client.id, state: this.players[i].state, seq: this.players[i].sequence, timestamp: currentTime });
|
||||
this.players[i].client.broadcast.emit('update', { id: this.players[i].client.id, state: this.players[i].state, seq: this.players[i].sequence, timestamp: currentTime });
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user