mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-06-27 16:10:34 +08:00
Upgraded to Socket.IO v1.1
This commit is contained in:
+11
-11
@@ -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 ]);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
"dependencies": {
|
||||
"express": "3.1.0",
|
||||
"jade": "*",
|
||||
"socket.io": "0.9.14"
|
||||
"socket.io": "1.1.0"
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ $(function () {
|
||||
|
||||
window.addEventListener('resize', resizeCanvas, false);
|
||||
|
||||
GarageServerIO.initializeGarageServer('http://garageserver_io.jbillmann.c9.io', {
|
||||
GarageServerIO.initializeGarageServer('https://garageserver_io-c9-jbillmann.c9.io', {
|
||||
logging: true,
|
||||
onReady: startGame,
|
||||
onUpdatePlayerPrediction: GamePhysics.getNewPlayerState,
|
||||
|
||||
Reference in New Issue
Block a user