Added JSDoc for Class Members of src/app/channel/*
This commit is contained in:
parent
1aa836ba48
commit
f34ad4829c
110 changed files with 6072 additions and 317 deletions
|
|
@ -32,14 +32,39 @@ class activeChannel{
|
|||
* @param {Mongoose.Document} chanDB - chanDB to rehydrate buffer from
|
||||
*/
|
||||
constructor(server, chanDB){
|
||||
/**
|
||||
* Parent Server Object
|
||||
*/
|
||||
this.server = server;
|
||||
|
||||
/**
|
||||
* Current Channel Name
|
||||
*/
|
||||
this.name = chanDB.name;
|
||||
|
||||
/**
|
||||
* List of channel-wide toke commands
|
||||
*/
|
||||
this.tokeCommands = chanDB.tokeCommands;
|
||||
//Keeping these in a map was originally a vestige but it's more preformant than an array or object so :P
|
||||
|
||||
/**
|
||||
* List of connected users
|
||||
*/
|
||||
this.userList = new Map();
|
||||
|
||||
/**
|
||||
* Child Queue Object
|
||||
*/
|
||||
this.queue = new queue(server, chanDB, this);
|
||||
|
||||
/**
|
||||
* Child Playlist Handler Object
|
||||
*/
|
||||
this.playlistHandler = new playlistHandler(server, chanDB, this);
|
||||
//Define the chat buffer
|
||||
|
||||
/**
|
||||
* Child Chat Buffer Object
|
||||
*/
|
||||
this.chatBuffer = new chatBuffer(server, chanDB, this);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,15 +36,20 @@ class channelManager{
|
|||
* @param {Server} io - Socket.io server instanced passed down from server.js
|
||||
*/
|
||||
constructor(io){
|
||||
//Set the socket.io server
|
||||
/**
|
||||
* Socket.io server instance passed down from server.js
|
||||
*/
|
||||
this.io = io;
|
||||
|
||||
//Load
|
||||
/**
|
||||
* Map containing all active channels running on the server
|
||||
*/
|
||||
this.activeChannels = new Map;
|
||||
|
||||
//Load server components
|
||||
/**
|
||||
* Global Chat Handler Object
|
||||
*/
|
||||
this.chatHandler = new chatHandler(this);
|
||||
//this.mediaYanker = new mediaYanker(this);
|
||||
|
||||
//Handle connections from socket.io
|
||||
io.on("connection", this.handleConnection.bind(this) );
|
||||
|
|
|
|||
|
|
@ -28,11 +28,34 @@ class chat{
|
|||
* @param {Array} links - Array of URLs/Links included in the message.
|
||||
*/
|
||||
constructor(user, flair, highLevel, msg, type, links){
|
||||
/**
|
||||
* User who sent the message
|
||||
*/
|
||||
this.user = user;
|
||||
|
||||
/**
|
||||
* Flair ID String for the flair used to send the message
|
||||
*/
|
||||
this.flair = flair;
|
||||
|
||||
/**
|
||||
* Number representing current high level
|
||||
*/
|
||||
this.highLevel = highLevel;
|
||||
|
||||
/**
|
||||
* COntents of the message, with links replaced with numbered file-seperator marks
|
||||
*/
|
||||
this.msg = msg;
|
||||
|
||||
/**
|
||||
* Message Type Identifier, used for client-side processing.
|
||||
*/
|
||||
this.type = type;
|
||||
|
||||
/**
|
||||
* Array of URLs/Links included in the message.
|
||||
*/
|
||||
this.links = links;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,26 +27,48 @@ class chatBuffer{
|
|||
* @param {activeChannel} channel - Parent Channel Object
|
||||
*/
|
||||
constructor(server, chanDB, channel){
|
||||
//Grab parent server and chan objects
|
||||
/**
|
||||
* Parent Server Object
|
||||
*/
|
||||
this.server = server;
|
||||
|
||||
/**
|
||||
* Parent CHannel Object
|
||||
*/
|
||||
this.channel = channel;
|
||||
|
||||
//If we have no chanDB.chatBuffer
|
||||
if(chanDB == null || chanDB.chatBuffer == null){
|
||||
//Create RAM-based buffer array
|
||||
/**
|
||||
* RAM-Based buffer containing array of previous chats
|
||||
*/
|
||||
this.buffer = [];
|
||||
//Otherwise
|
||||
}else{
|
||||
//Pull buffer from DB
|
||||
/**
|
||||
* RAM-Based buffer containing array of previous chats
|
||||
*/
|
||||
this.buffer = chanDB.chatBuffer;
|
||||
}
|
||||
|
||||
//Create variables to hold timers for deciding when to write RAM buffer to DB
|
||||
//Goes off 'this.inactivityDelay' seconds after the last chat was sent, assuming it isn't interrupted by new chats
|
||||
/**
|
||||
* Inactivity Timer, goes off after x seconds of chat inactivity
|
||||
*/
|
||||
this.inactivityTimer = null;
|
||||
|
||||
/**
|
||||
* Inactivity Timer Delay
|
||||
*/
|
||||
this.inactivityDelay = 10;
|
||||
//Goes off 'this.busyDelay' minutes after the first chat message in the current volley of messages. Get's cancelled before being called if this.inactivityTimer goes off.
|
||||
|
||||
/**
|
||||
* Goes off after x minutes of solid chatroom activity (no inactivityTimer call in x minutes)
|
||||
*/
|
||||
this.busyTimer = null;
|
||||
|
||||
/**
|
||||
* Busy Timer Delay
|
||||
*/
|
||||
this.busyDelay = 5;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,11 +34,19 @@ class chatHandler{
|
|||
* @param {channelManager} server - Parent Server Object
|
||||
*/
|
||||
constructor(server){
|
||||
//Set server
|
||||
/**
|
||||
* Parent Server Object
|
||||
*/
|
||||
this.server = server;
|
||||
//Initialize command preprocessor
|
||||
|
||||
/**
|
||||
* Child Command Pre-Processor Object
|
||||
*/
|
||||
this.commandPreprocessor = new commandPreprocessor(server, this)
|
||||
//Max chat buffer size
|
||||
|
||||
/**
|
||||
* Max chat buffer message count
|
||||
*/
|
||||
this.chatBufferSize = 50;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,9 +33,24 @@ class commandPreprocessor{
|
|||
* @param {chatHandler} chatHandler - Parent Chat Handler Object
|
||||
*/
|
||||
constructor(server, chatHandler){
|
||||
/**
|
||||
* Parent Server Object
|
||||
*/
|
||||
this.server = server;
|
||||
|
||||
/**
|
||||
* Parent Chat Handler Object
|
||||
*/
|
||||
this.chatHandler = chatHandler;
|
||||
|
||||
/**
|
||||
* Child Command Processor Object
|
||||
*/
|
||||
this.commandProcessor = new commandProcessor(server, chatHandler);
|
||||
|
||||
/**
|
||||
* Child Tokebot Object
|
||||
*/
|
||||
this.tokebot = new tokebot(server, chatHandler);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,23 +34,55 @@ class connectedUser{
|
|||
* @param {Socket} socket - Socket associated with the users connection
|
||||
*/
|
||||
constructor(userDB, chanRank, channel, socket){
|
||||
/**
|
||||
* User ID Number
|
||||
*/
|
||||
this.id = userDB.id;
|
||||
|
||||
/**
|
||||
* User Name
|
||||
*/
|
||||
this.user = userDB.user;
|
||||
|
||||
/**
|
||||
* User Rank
|
||||
*/
|
||||
this.rank = userDB.rank;
|
||||
|
||||
/**
|
||||
* User High-Level
|
||||
*/
|
||||
this.highLevel = userDB.highLevel;
|
||||
|
||||
//Check to make sure users flair entry from DB is good
|
||||
if(userDB.flair != null){
|
||||
//Use flair from DB
|
||||
//Set flair from DB
|
||||
/**
|
||||
* User Flair
|
||||
*/
|
||||
this.flair = userDB.flair.name;
|
||||
//Otherwise
|
||||
}else{
|
||||
//Gracefully default to classic
|
||||
/**
|
||||
* User Flair
|
||||
*/
|
||||
this.flair = 'classic';
|
||||
}
|
||||
|
||||
/**
|
||||
* User Channel-Rank
|
||||
*/
|
||||
this.chanRank = chanRank;
|
||||
|
||||
/**
|
||||
* Connected Channel
|
||||
*/
|
||||
this.channel = channel;
|
||||
|
||||
/**
|
||||
* List of active sockets to current channel
|
||||
*/
|
||||
this.sockets = [socket.id];
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,12 +29,39 @@ class media{
|
|||
* @param {String} rawLink - URL to raw file copy of media, not applicable to all sources
|
||||
*/
|
||||
constructor(title, fileName, url, id, type, duration, rawLink = url){
|
||||
/**
|
||||
* Chosen title of media
|
||||
*/
|
||||
this.title = title;
|
||||
|
||||
/**
|
||||
* Original filename/title of media provided by source
|
||||
*/
|
||||
this.fileName = fileName
|
||||
|
||||
/**
|
||||
* Original URL to file
|
||||
*/
|
||||
this.url = url;
|
||||
|
||||
/**
|
||||
* Video ID from source (IE: youtube watch code/archive.org file path)
|
||||
*/
|
||||
this.id = id;
|
||||
|
||||
/**
|
||||
* Original video source
|
||||
*/
|
||||
this.type = type;
|
||||
|
||||
/**
|
||||
* Length of media in seconds
|
||||
*/
|
||||
this.duration = duration;
|
||||
|
||||
/**
|
||||
* URL to raw file copy of media, not applicable to all sources
|
||||
*/
|
||||
this.rawLink = rawLink;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,9 +34,14 @@ class playlistHandler{
|
|||
* @param {activeChannel} channel - Parent Channel object for desired channel queue
|
||||
*/
|
||||
constructor(server, channel){
|
||||
//Set server
|
||||
/**
|
||||
* Parent Server Object
|
||||
*/
|
||||
this.server = server
|
||||
//Set channel
|
||||
|
||||
/**
|
||||
* Parent Channel Object for desired channel queue
|
||||
*/
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,38 +34,67 @@ class queue{
|
|||
* @param {activeChannel} channel - Parent Channel object for desired channel queue
|
||||
*/
|
||||
constructor(server, chanDB, channel){
|
||||
//Set server
|
||||
/**
|
||||
* Parent Server Object
|
||||
*/
|
||||
this.server = server
|
||||
//Set channel
|
||||
/**
|
||||
* Parent Chennel Object for desired channel queue
|
||||
*/
|
||||
this.channel = channel;
|
||||
|
||||
//Create map to hold currently queued media
|
||||
/**
|
||||
* Map containing current schedule
|
||||
*/
|
||||
this.schedule = new Map();
|
||||
|
||||
//Create variable to hold sync delta in ms
|
||||
/**
|
||||
* Sync Delta in MS
|
||||
*/
|
||||
this.syncDelta = 1000;
|
||||
//Create variable to hold current timestamp within the video
|
||||
/**
|
||||
* Current Timestamp in Media
|
||||
*/
|
||||
this.timestamp = 0;
|
||||
//Delay between pre-switch function call and start of media
|
||||
//This should be enough time to do things like pre-fetch updated raw links from youtube
|
||||
/**
|
||||
* Time before media switch to run pre-switch method call against next media
|
||||
*/
|
||||
this.preSwitchDelta = 10 * 1000;
|
||||
|
||||
//Create variable to hold sync timer
|
||||
/**
|
||||
* Syncronization Timer
|
||||
*/
|
||||
this.syncTimer = null;
|
||||
//Create variable to hold next playing item timer
|
||||
/**
|
||||
* Next Media Timer
|
||||
*/
|
||||
this.nextTimer = null;
|
||||
//Create vairable to hold pre-switch timer
|
||||
/**
|
||||
* Next Media Pre-Switch Timer
|
||||
*/
|
||||
this.preSwitchTimer = null;
|
||||
//Create variable to hold currently playing media object
|
||||
/**
|
||||
* Currently Playing Media Item
|
||||
*/
|
||||
this.nowPlaying = null;
|
||||
//Create variable to hold item that was playing during the last liveStream (can't check against full duration since it might've been stopped for other reasons)
|
||||
/**
|
||||
* Media interrupted by current live-stream
|
||||
*/
|
||||
this.liveRemainder = null;
|
||||
//Create variable to hold current live mode
|
||||
/**
|
||||
* Current live-stream schedule mode
|
||||
*/
|
||||
this.liveMode = null;
|
||||
|
||||
//Create variable to lock standard queuing functions during livestreams
|
||||
/**
|
||||
* Locks scheduling functionality during livestreams
|
||||
*/
|
||||
this.streamLock = false;
|
||||
//create boolean to hold schedule lock
|
||||
/**
|
||||
* Locks schedule upon admin request
|
||||
*/
|
||||
this.locked = false;
|
||||
|
||||
//Rehydrate channel queue from database
|
||||
|
|
|
|||
|
|
@ -32,13 +32,25 @@ class queuedMedia extends media{
|
|||
constructor(title, fileName, url, id, type, duration, rawLink, startTime, startTimeStamp = 0, earlyEnd, uuid){
|
||||
//Call derived constructor
|
||||
super(title, fileName, url, id, type, duration, rawLink);
|
||||
//Set media start time
|
||||
|
||||
/**
|
||||
* JS Epoch (millis) representing start time
|
||||
*/
|
||||
this.startTime = startTime;
|
||||
//Set the media start time stamp
|
||||
|
||||
/**
|
||||
* Media start time stamp in seconds (relative to duration)
|
||||
*/
|
||||
this.startTimeStamp = startTimeStamp;
|
||||
//Create empty variable to hold early end if media is stopped early
|
||||
|
||||
/**
|
||||
* Media ent timestamp in seconds (relative to duration)
|
||||
*/
|
||||
this.earlyEnd = earlyEnd;
|
||||
//Set status for discriminator key
|
||||
|
||||
/**
|
||||
* Media status type
|
||||
*/
|
||||
this.status = 'queued';
|
||||
|
||||
//If we have a null uuid (can't use default argument because of 'this')
|
||||
|
|
@ -47,6 +59,9 @@ class queuedMedia extends media{
|
|||
//That way even if we have six copies of the same video queued, we can still uniquely idenitify each instance
|
||||
this.genUUID();
|
||||
}else{
|
||||
/**
|
||||
* Media object's unique identifier
|
||||
*/
|
||||
this.uuid = uuid;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,23 +30,49 @@ class tokebot{
|
|||
* @param {chatHandler} chatHandler - Parent Chat Handler Object
|
||||
*/
|
||||
constructor(server, chatHandler){
|
||||
//Set parents
|
||||
/**
|
||||
* Parent Server Object
|
||||
*/
|
||||
this.server = server;
|
||||
|
||||
/**
|
||||
* Parent Chat Handler
|
||||
*/
|
||||
this.chatHandler = chatHandler;
|
||||
|
||||
//Set timeouts to null
|
||||
/**
|
||||
* Toke Timer
|
||||
*/
|
||||
this.tokeTimer = null;
|
||||
|
||||
/**
|
||||
* Cooldown Timer
|
||||
*/
|
||||
this.cooldownTimer = null;
|
||||
|
||||
//Set start times
|
||||
/**
|
||||
* Toke time
|
||||
*/
|
||||
this.tokeTime = 60;
|
||||
|
||||
/**
|
||||
* Cooldown Time
|
||||
*/
|
||||
this.cooldownTime = 120;
|
||||
|
||||
//Create counter variable
|
||||
/**
|
||||
* Toke Counter
|
||||
*/
|
||||
this.tokeCounter = 0;
|
||||
|
||||
/**
|
||||
* Cooldown Counter
|
||||
*/
|
||||
this.cooldownCounter = 0;
|
||||
|
||||
//Create tokers list
|
||||
/**
|
||||
* List of current tokers
|
||||
*/
|
||||
this.tokers = new Map();
|
||||
|
||||
//Load in toke commands from the DB
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue