mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
fixed #38
This commit is contained in:
parent
7a59e175e0
commit
89c5e4a5d8
6 changed files with 64 additions and 25 deletions
|
|
@ -45,6 +45,19 @@
|
|||
// Channel command callbacks
|
||||
|
||||
Channel.prototype.onAddUser = function (userId) {
|
||||
var self = this;
|
||||
|
||||
if(!this.gameController.level || !this.gameController.level.isLoaded) {
|
||||
var token = NotificationCenter.on("game/level/loaded", function() {
|
||||
self.sendJoinSuccess(userId);
|
||||
NotificationCenter.off(token);
|
||||
});
|
||||
} else {
|
||||
self.sendJoinSuccess(userId);
|
||||
}
|
||||
}
|
||||
|
||||
Channel.prototype.sendJoinSuccess = function(userId) {
|
||||
var user = new User(userId, this);
|
||||
var joinedUsers = Object.keys(this.users);
|
||||
var spawnedPlayers = this.gameController.getSpawnedPlayersAndTheirPositions();
|
||||
|
|
@ -64,11 +77,11 @@
|
|||
spawnedPlayers: spawnedPlayers,
|
||||
worldUpdate: worldUpdate,
|
||||
levelUid: levelUid
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
NotificationCenter.trigger('user/' + user.id + "/joinSuccess", options);
|
||||
NotificationCenter.trigger('user/joined', user);
|
||||
}
|
||||
NotificationCenter.trigger('user/joined', user);
|
||||
};
|
||||
|
||||
Channel.prototype.onReleaseUser = function (userId) {
|
||||
var user = this.users[userId];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue