mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
moved files towards new structure. fixes #22
This commit is contained in:
parent
8cf8f057bb
commit
9de3147406
40 changed files with 0 additions and 110 deletions
|
|
@ -1,53 +0,0 @@
|
|||
define(["Server/User", "Server/Channel", "Server/Factory"], function(User, Channel, Factory) {
|
||||
|
||||
function Coordinator() {
|
||||
this.channels = {};
|
||||
this.lobbyUsers = {};
|
||||
}
|
||||
|
||||
Coordinator.prototype.createUser = function(socketLink){
|
||||
var user = new User(socketLink, this);
|
||||
this.assignUserToLobby(user);
|
||||
}
|
||||
|
||||
Coordinator.prototype.assignUserToLobby = function(user){
|
||||
if(user.channel) {
|
||||
user.channel.releaseUser(user);
|
||||
}
|
||||
this.lobbyUsers[user.id] = user;
|
||||
}
|
||||
|
||||
Coordinator.prototype.assignUserToChannel = function(user, channelName){
|
||||
|
||||
if(user.channel) {
|
||||
user.channel.releaseUser(user);
|
||||
}
|
||||
|
||||
if(!Channel.validateName(channelName)){
|
||||
//TODO send validation error
|
||||
return false;
|
||||
}
|
||||
|
||||
var channel = this.channels[channelName];
|
||||
if(!channel) {
|
||||
var factory = new Factory();
|
||||
channel = factory.new(Channel, channelName);
|
||||
this.channels[channelName] = channel;
|
||||
}
|
||||
|
||||
channel.addUser(user);
|
||||
user.setChannel(channel);
|
||||
|
||||
delete this.lobbyUsers[user.id];
|
||||
}
|
||||
|
||||
Coordinator.prototype.removeUser = function(user){
|
||||
delete this.lobbyUsers[user.id];
|
||||
if(user.channel) {
|
||||
user.channel.releaseUser(user);
|
||||
}
|
||||
}
|
||||
|
||||
return Coordinator;
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue