Moved server-side queue transmission to it's own protected namespace.
This commit is contained in:
parent
5eb307bb9e
commit
6d16ac2353
5 changed files with 28 additions and 11 deletions
|
|
@ -226,9 +226,6 @@ class connectedUser{
|
|||
}
|
||||
});
|
||||
|
||||
//Get schedule as a temporary array
|
||||
const queue = await this.channel.queue.prepQueue(chanDB);
|
||||
|
||||
//Get schedule lock status
|
||||
const queueLock = this.channel.queue.locked;
|
||||
|
||||
|
|
@ -236,7 +233,7 @@ class connectedUser{
|
|||
const chatBuffer = this.channel.chatBuffer.buffer;
|
||||
|
||||
//Send off the metadata to our user's clients
|
||||
this.emit("clientMetadata", {user: userObj, flairList, queue, queueLock, chatBuffer});
|
||||
this.emit("clientMetadata", {user: userObj, flairList, queueLock, chatBuffer});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1607,7 +1607,18 @@ class queue{
|
|||
* @param {Mongoose.Document} chanDB - Pass through Channel Document to save on DB Transactions
|
||||
*/
|
||||
async broadcastQueue(chanDB){
|
||||
this.server.io.in(this.channel.name).emit('queue',{queue: await this.prepQueue(chanDB)});
|
||||
//Broadcast queue to authenticated sockets within the channels room inside the protected 'queue-broadcast' namespace
|
||||
this.server.queueBroadcastManager.namespace.in(this.channel.name).emit('queue',{queue: await this.prepQueue(chanDB)});
|
||||
}
|
||||
|
||||
/**
|
||||
* Broadcasts channel queue to a single socket
|
||||
* @param {Mongoose.Document} chanDB - Pass through Channel Document to save on DB Transactions
|
||||
* @param {Socket} socket - Socket to send queue to
|
||||
*/
|
||||
async emitQueue(chanDB, socket){
|
||||
//Broadcast queue to authenticated sockets within the channels room inside the protected 'queue-broadcast' namespace
|
||||
socket.emit('queue',{queue: await this.prepQueue(chanDB)});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -55,6 +55,15 @@ class queueBroadcastManager extends auxServer{
|
|||
|
||||
//Set socket channel value
|
||||
socket.chan = socketUtils.getChannelName(socket);
|
||||
//Pull active channel
|
||||
const activeChannel = this.chanServer.activeChannels.get(socket.chan);
|
||||
|
||||
//If there isn't an active channel
|
||||
if(activeChannel == null){
|
||||
//Drop the connection
|
||||
return;
|
||||
}
|
||||
|
||||
//Pull channel DB
|
||||
const chanDB = (await channelModel.findOne({name: socket.chan}));
|
||||
|
||||
|
|
@ -69,6 +78,9 @@ class queueBroadcastManager extends auxServer{
|
|||
//Throw the user into the channels room within the queue-broadcast instance
|
||||
socket.join(socket.chan);
|
||||
|
||||
//Send the queue down to our newly connected user
|
||||
activeChannel.queue.emitQueue(chanDB, socket);
|
||||
|
||||
//Define listeners
|
||||
this.defineListeners(socket);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue