mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 18:47:35 +00:00
add users on join
This commit is contained in:
parent
e43fbc5223
commit
e751210345
2 changed files with 9 additions and 1 deletions
|
|
@ -53,6 +53,12 @@ define(["Protocol/Helper", "Chuck/ClientGame"], function(ProtocolHelper, ClientG
|
||||||
this.clientGame = new ClientGame(this, options.id);
|
this.clientGame = new ClientGame(this, options.id);
|
||||||
this.clientGame.loadLevel("default.json")
|
this.clientGame.loadLevel("default.json")
|
||||||
console.log("Joined " + options.channelName);
|
console.log("Joined " + options.channelName);
|
||||||
|
|
||||||
|
if (options.userIds && options.userIds.length > 0) {
|
||||||
|
for(var i = 0; i < options.userIds.length; i++) {
|
||||||
|
this.clientGame.userJoined(options.userIds[i])
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Networker.prototype.onUserJoined = function(userId) {
|
Networker.prototype.onUserJoined = function(userId) {
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,11 @@ define(["Chuck/ServerGame"], function(ServerGame) {
|
||||||
}
|
}
|
||||||
|
|
||||||
Channel.prototype.addUser = function(user){
|
Channel.prototype.addUser = function(user){
|
||||||
|
var userIds = Object.keys(this.users);
|
||||||
|
|
||||||
this.users[user.id] = user;
|
this.users[user.id] = user;
|
||||||
|
|
||||||
user.sendCommand('joinSuccess', {channelName: this.name, id: user.id});
|
user.sendCommand('joinSuccess', {channelName: this.name, id: user.id, userIds: userIds});
|
||||||
this.sendCommandToAllUsersExcept('userJoined', user.id, user);
|
this.sendCommandToAllUsersExcept('userJoined', user.id, user);
|
||||||
|
|
||||||
this.serverGame.createPlayerForUser(user)
|
this.serverGame.createPlayerForUser(user)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue