Added kickConnections to channelManager
This commit is contained in:
parent
0432c9d1cc
commit
b138b26f27
6 changed files with 37 additions and 15 deletions
|
|
@ -152,21 +152,33 @@ module.exports = class{
|
|||
return chanList;
|
||||
}
|
||||
|
||||
getConnections(socket){
|
||||
//Create a list to store our connections
|
||||
var connections = [];
|
||||
|
||||
crawlConnections(user, cb){
|
||||
//For each channel
|
||||
this.activeChannels.forEach((channel) => {
|
||||
//Check and see if the user is connected
|
||||
const foundUser = channel.userList.get(socket.user.user);
|
||||
const foundUser = channel.userList.get(user);
|
||||
|
||||
//If we found a user and this channel hasn't been added to the list
|
||||
if(foundUser){
|
||||
connections.push(foundUser);
|
||||
cb(foundUser);
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
getConnections(user){
|
||||
//Create a list to store our connections
|
||||
var connections = [];
|
||||
|
||||
//crawl through connections
|
||||
//this.crawlConnections(user,(foundUser)=>{connections.push(foundUser)});
|
||||
this.crawlConnections(user,(foundUser)=>{connections.push(foundUser)});
|
||||
|
||||
//return connects
|
||||
return connections;
|
||||
}
|
||||
|
||||
kickConnections(user, reason){
|
||||
//crawl through connections and kick user
|
||||
this.crawlConnections(user,(foundUser)=>{foundUser.disconnect(reason)});
|
||||
}
|
||||
}
|
||||
|
|
@ -61,7 +61,7 @@ module.exports = class{
|
|||
userDB.flair = data.flair;
|
||||
userDB = await userDB.save();
|
||||
|
||||
const connections = this.server.getConnections(socket);
|
||||
const connections = this.server.getConnections(socket.user.user);
|
||||
|
||||
connections.forEach((conn) => {
|
||||
conn.updateFlair(userDB.flair);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue