mirror of
https://github.com/wassname/GarageServer.IO.git
synced 2026-06-27 16:10:34 +08:00
Added events
This commit is contained in:
@@ -7,12 +7,18 @@ options = {
|
||||
onEntityUpdate: function (state),
|
||||
onPlayerRemove: function (id),
|
||||
onEntityRemove: function (id),
|
||||
onEvent: function (data),
|
||||
onWorldState: function (state),
|
||||
onPing: function (pingDelay),
|
||||
onUpdatePlayerPhysics: function (state, inputs, deltaTime),
|
||||
onInterpolation: function(previousState, targetState, amount)
|
||||
logging: true
|
||||
}
|
||||
api methods
|
||||
initializeGarageServer(path, options)
|
||||
addInput({})
|
||||
getStates(function (playerStates, entityStates))
|
||||
getId() : 0
|
||||
*/
|
||||
var GarageServerIO = (function (socketio) {
|
||||
|
||||
@@ -164,8 +170,8 @@ var GarageServerIO = (function (socketio) {
|
||||
_playerController = new PlayerController(),
|
||||
_entityController = new EntityController(),
|
||||
|
||||
initializeGarageServer = function (path, opts) {
|
||||
_options = opts;
|
||||
initializeGarageServer = function (path, options) {
|
||||
_options = options;
|
||||
_socket = _io.connect(path + '/garageserver.io');
|
||||
registerSocketEvents();
|
||||
},
|
||||
@@ -243,6 +249,14 @@ var GarageServerIO = (function (socketio) {
|
||||
console.log('garageserver.io:: socket removeEntity ' + id);
|
||||
}
|
||||
});
|
||||
_socket.on('event', function(data) {
|
||||
if (_options.onEvent) {
|
||||
_options.onEvent(data);
|
||||
}
|
||||
if (_options.logging) {
|
||||
console.log('garageserver.io:: socket event ' + data);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
getId = function () {
|
||||
|
||||
Reference in New Issue
Block a user