Upgraded to Socket.IO v1.1

This commit is contained in:
Jeremiah Billmann
2014-10-23 15:22:57 +00:00
parent 7fa638c940
commit 5c01c26530
3 changed files with 13 additions and 13 deletions
+11 -11
View File
@@ -187,7 +187,7 @@ var GarageServerIO = (function (socketio) {
registerSocketEvents = function () {
_socket.on('connect', function () {
_stateController.id = _socket.socket.sessionid;
_stateController.id = _socket.io.engine.id;
if (_options.logging) {
console.log('garageserver.io:: socket connect');
}
@@ -197,7 +197,7 @@ var GarageServerIO = (function (socketio) {
}
});
_socket.on('state', function (data) {
_socket.on('s', function (data) {
if (_options.onWorldState) {
_options.onWorldState(data.worldState);
}
@@ -219,11 +219,11 @@ var GarageServerIO = (function (socketio) {
}
setInterval(function (){
_socket.emit('ping', new Date().getTime());
_socket.emit('p', new Date().getTime());
}, _stateController.pingInterval);
});
_socket.on('disconnect', function () {
_socket.on('d', function () {
if (_options.logging) {
console.log('garageserver.io:: socket disconnect');
}
@@ -241,11 +241,11 @@ var GarageServerIO = (function (socketio) {
}
});
_socket.on('update', function (data) {
_socket.on('u', function (data) {
update(data);
});
_socket.on('ping', function (data) {
_socket.on('p', function (data) {
_stateController.pingDelay = new Date().getTime() - data;
if (_options.logging) {
console.log('garageserver.io:: socket ping delay ' + _stateController.pingDelay);
@@ -255,7 +255,7 @@ var GarageServerIO = (function (socketio) {
}
});
_socket.on('removePlayer', function (id) {
_socket.on('rp', function (id) {
removePlayer(id);
if (_options.logging) {
console.log('garageserver.io:: socket removePlayer ' + id);
@@ -265,7 +265,7 @@ var GarageServerIO = (function (socketio) {
}
});
_socket.on('removeEntity', function (id) {
_socket.on('re', function (id) {
removeEntity(id);
if (_options.logging) {
console.log('garageserver.io:: socket removeEntity ' + id);
@@ -275,7 +275,7 @@ var GarageServerIO = (function (socketio) {
}
});
_socket.on('event', function(data) {
_socket.on('e', function(data) {
if (_options.logging) {
console.log('garageserver.io:: socket event ' + data);
}
@@ -290,7 +290,7 @@ var GarageServerIO = (function (socketio) {
},
sendServerEvent = function (data) {
_socket.emit('event', data);
_socket.emit('e', data);
},
addInput = function (clientInput) {
@@ -300,7 +300,7 @@ var GarageServerIO = (function (socketio) {
player.inputController.add(clientInput);
player.state = _options.onUpdatePlayerPrediction(player.state, [{ input: clientInput }], _stateController.physicsDelta);
}
_socket.emit('input', [ clientInput, player.inputController.sequenceNumber, _stateController.renderTime ]);
_socket.emit('i', [ clientInput, player.inputController.sequenceNumber, _stateController.renderTime ]);
}
});
},