# JSDoc: Class: exports

# Class: exports

## exports(server, chanDB)

Class representing a single active channel

## Constructor

#### new exports(server, chanDB)

Instantiates an activeChannel object

##### Parameters:

Name | Type | Description
--- | --- | ---
`server` | channelManager | Parent Server Object
`chanDB` | Mongoose.Document | chanDB to rehydrate buffer from

Source:
  - app/channel/activeChannel.js, line 27

### Methods

#### (async) addPersonalEmote(socket, data)

Handles incoming client request to add a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 123

#### (async) addToChannelPlaylist(socket, data, chanDB)

Adds media to channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 434

#### (async) addToPlaylistValidator(socket, URL) → {Array}

Validates client requests to add media to a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`URL` | String | URL String handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 116

##### Returns:

List of media objects which where added

Type
  Array

#### (async) addToUserPlaylist(socket, data, userDB)

Adds media to user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 485

#### (async) asyncFinisher()

This method seems to be a vestage from a bygone era. We should remove it after documenting shit. I would now, but I don't want to break shit in a comment-only commit.

Source:
  - app/channel/tokebot.js, line 194

#### (async) authSocket(socket) → {Mongoose.Document}

Global server-side authorization logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 152

##### Returns:

- Authorized User Document upon success

Type
  Mongoose.Document

#### (async) broadcastChanEmotes(chanDB)

Broadcasts channel emote list to connected users

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/activeChannel.js, line 140

#### (async) broadcastQueue(chanDB)

Broadcasts channel queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1573

#### (async) broadcastSiteEmotes()

Broadcast global emote list

Source:
  - app/channel/channelManager.js, line 297

#### broadcastUserList()

Broadcasts user list to all users

Source:
  - app/channel/activeChannel.js, line 117

#### (async) changeDefaultTitlesChannelPlaylist(socket, data, chanDB)

Changes default titles for a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 968

#### (async) changeDefaultTitlesUserPlaylist(socket, data, userDB)

Changes default titles for a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1008

#### changeDefaultTitlesValidator(data) → {Array}

Validates client requests to change default titles for a given playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 188

##### Returns:

Array of strings containing valid titles from the output

Type
  Array

#### clearChat(user, chan)

Clears chat for a given channel, targets specified user or entire channel if none found/specified.

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | User chats to clear
`chan` | String | Channel to broadcast message within

Source:
  - app/channel/chatHandler.js, line 320

#### cooldown()

Runs every second for 60 seconds after a toke

Source:
  - app/channel/tokebot.js, line 205

#### countdown()

Called each second during the toke. Handles decrementing the timer variable, and countdown end logic.

Source:
  - app/channel/tokebot.js, line 148

#### crawlConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 254

#### (async) createChannelPlaylist(socket, data, chanDB)

Creates a new channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 270

#### createPlaylistValidator(socket, data) → {Object}

Validates client requests to create a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 80

##### Returns:

returns validated titles

Type
  Object

#### (async) createUserPlaylist(socket, data, userDB)

Creates a new user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 319

#### defineListeners(socket)

Define Global Server-Side socket event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 200

#### defineListeners(socket)

Defines global server-side chat relay event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/chatHandler.js, line 49

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/playlistHandler.js, line 47

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/queue.js, line 79

#### (async) deleteChannelPlaylist(socket, data, userDB)

Deletes a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 367

#### (async) deleteChannelPlaylistMedia(socket, data, chanDB)

Deletes media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1048

#### (async) deleteMedia(socket, data)

Processes client requests to delete queued media

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 178

#### (async) deletePersonalEmote(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 158

#### deletePlaylistMediaValidator(socket, data)

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 210

#### (async) deleteRange(socket, data)

Processes request to delete a range of media items from the queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 205

#### (async) deleteUserPlaylist(socket, data, chanDB)

Deletes a Channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 401

#### (async) deleteUserPlaylistMedia(socket, data, userDB)

Deletes media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1097

#### disconnect(reason, type)

Disconnects all sockets for a given user

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`reason` | String |  | Reason for being disconnected
`type` | String | Disconnected | Disconnection Type

Source:
  - app/channel/connectedUser.js, line 129

#### emit(eventName, data)

Emits an event to all known sockets for a given user My brain keeps going back to using dynamic per-user namespaces for this but everytime i look into it I come to the conclusion that it's a bad idea, then I toy with making chans namespaces and using per-user channels for this, but what of gold or mod-only features? or games? No matter what it'd probably end up hacky, as namespaces where meant for splitting app logic not user comms (like rooms). at the end of the day there has to be some penance for decent multi-session handling on-top of a library that doesn't do it. Having to crawl through these sockets is that. Because the other ways seem more gross somehow.

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventName` | String | Event name to emit to client sockets
`data` | Object | Data to emit to client sockets

Source:
  - app/channel/connectedUser.js, line 115

#### (async) end(quiet, noArchive, volatile, chanDB)

End currently playing media

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`quiet` | Boolean | false | Enable to prevent ending the media client-side
`noArchive` | Boolean | false | Enable to prevent ended media from being written to channel archive. Deletes media if Volatile is false
`volatile` | Boolean | false | Enable to prevent DB Transactions
`chanDB` | Mongoose.Document |  | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1099

#### (async) endLivestream(wasPlaying, chanDB)

Ends running Livestream

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1183

#### fromMedia(media, startTime, startTimeStamp) → {queuedMedia}

Creates a queuedMedia object from a media object

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | media | Media object to queue
`startTime` | Number | Start time formatted as a JS Epoch
`startTimeStamp` | Number | Start time stamp in seconds

Source:
  - app/channel/media/queuedMedia.js, line 62

##### Returns:

queuedMedia object created from given media object

Type
  queuedMedia

#### fromMediaArray(mediaList, start)

Converts array of media objects into array of queuedMedia objects

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaList` | Array | Array of media objects to queue
`start` | Number | Start time formatted as JS Epoch

Source:
  - app/channel/media/queuedMedia.js, line 82

##### Returns:

Array of converted queued media objects

#### genUUID()

Generates new unique identifier for queued media

Source:
  - app/channel/media/queuedMedia.js, line 103

#### (async) getActiveChan(socket) → {Object}

Gets active channel from a given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 174

##### Returns:

Object containing users active channel name and channel document object

Type
  Object

#### (async) getChannelPlaylists(socket, chanDB)

Sends channel playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 228

#### getConnectedChannels(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 230

##### Returns:

returns related user info

#### getConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 272

#### getEndTime(fullTime)

return the end time of a given queuedMedia object

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`fullTime` | boolean | false | Overrides early ends

Source:
  - app/channel/media/queuedMedia.js, line 112

##### Returns:

end time of given queuedMedia object

#### getItemAtEpoch(epoch) → {queuedMedia}

Gets a media item by epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis)

Source:
  - app/channel/media/queue.js, line 1471

##### Returns:

found media item

Type
  queuedMedia

#### getItemByUUID(uuid) → {queuedMedia}

Get Scheduled Item by UUID

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule

Source:
  - app/channel/media/queue.js, line 1535

##### Returns:

found item

Type
  queuedMedia

#### getItemsBetweenEpochs(start, end, noUnfinished) → {queuedMedia}

Returns scheduled media between two given datetimes

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (Millis)
`end` | Number |  | End date by JS Epoch (Millis)
`noUnfinished` | Boolean | false | Enable to include currently playing media

Source:
  - app/channel/media/queue.js, line 1446

##### Returns:

Found Media Objects

Type
  queuedMedia

#### getLastItem(epoch)

Gets last item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1490

##### Returns:

Last played item

#### getNextItem(epoch) → {queuedMedia}

Gets next item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1520

##### Returns:

Next item on the schedule

Type
  queuedMedia

#### getSocketInfo(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 220

##### Returns:

returns related user info

#### getStart(start)

Validates start times, and replaces bad ones with 5ms in the future

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | Start time to validate by JS Epoch (millis)

Source:
  - app/channel/media/queue.js, line 407

##### Returns:

Start time as JS Epoch (millis)

#### (async) getUserPlaylists(socket, userDB)

Sends user playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`userDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 248

#### (async) goLive(socket, data)

Handle client request to start an HLS live stream

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 289

#### handleChat(socket, data)

Handles incoming chat messages from client connections

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 62

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections to the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 53

#### (async) handleConnection(socket)

Handles global server-side initialization for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 57

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections from a specific user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/connectedUser.js, line 63

#### handleDisconnect(socket)

Handles server-side initialization for disconnecting from the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 92

#### handleDisconnect(socket, reason)

Global server-side logic for handling disconncted sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check
`reason` | String | Reason for disconnection

Source:
  - app/channel/channelManager.js, line 210

#### (async) handleRawRefresh(mediaObj) → {queuedMedia}

Refreshes expired raw links before media plays

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 978

##### Returns:

passes through Media object with updated link upon success

Type
  queuedMedia

#### kickConnections(user, reason)

Kicks a user from all channels by username

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to kick from the server
`reason` | String | Reason for kick

Source:
  - app/channel/channelManager.js, line 289

#### (async) livestreamOverwriteSchedule(wasPlaying, chanDB)

Overwrites livestream over scheduled media content after it has ended

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1239

#### (async) livestreamPushbackSchedule(wasPlaying, chanDB)

Pushes back any missed content scheduled during Livestream after Livestream has ended.

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1328

#### (async) markLinks(commandObj)

Iterates through links in message and marks them by link type for later use by client-side post-processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 126

#### (async) moveMedia(socket, data)

Processes request to move queued media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 238

#### (async) preSwitch(mediaObj)

Called 10 seconds before media begins to play

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 969

#### (async) prepMessage(commandObj)

Re-creates message string from processed Command Array

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 142

#### (async) prepQueue(chanDB)

Prepares channel queue for network transmission

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1582

##### Returns:

de-hydrated scehdule information

#### (async) preprocess(socket, data)

Ingests a command/chat request from Chat Handler and pre-processes and processes it accordingly

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/commandPreprocessor.js, line 47

#### (async) processServerCommand(commandObj)

Uses the server's Command Processor object to process the chat/command request.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 105

#### (async) queueChannelPlaylist(socket, data, chanDB)

Queues an entire channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 533

#### (async) queueFromChannelPlaylist(socket, data, chanDB)

Queues media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 646

#### queueFromChannelPlaylistValidator(socket, data) → {Number}

Validates client requests to queue media from a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 151

##### Returns:

returns validated start time on success

Type
  Number

#### (async) queueFromUserPlaylist(socket, data, userDB, chanDB)

Queues media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 697

#### (async) queueRandomFromChannelPlaylist(socket, data, chanDB)

Queues random media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 753

#### (async) queueRandomFromUserPlaylist(socket, data, userDB, chanDB)

Queues random media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 801

#### (async) queueURL(socket, data)

Accepts new URL's to queue from the client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the URL from
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 96

#### (async) queueUserPlaylist(socket, data, userDB, chanDB)

Queues an entire user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 587

#### (async) refreshCommands()

Reloads toke commands from DB into RAM-based toke command store

Source:
  - app/channel/tokebot.js, line 59

#### refreshNextTimer(volatile)

Calculates next item to play, and sets timer to play it at it's scheduled start

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`volatile` | Boolean | false | Disables DB Transactions if true

Source:
  - app/channel/media/queue.js, line 442

#### (async) rehydrateQueue(chanDB)

Rehydrates media schedule from DB

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1640

#### relayChannelAnnouncement(msg, links)

Broadcasts announcement to a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 305

#### relayChat(user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given channel

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`chan` | String |  | Channel to broadcast message within
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 179

#### relayChatObject(chan, chat)

Relays an existing chat object to a channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`chan` | String | Channel to broadcast message within
`chat` | chat | Chat Object representing the message to broadcast to the given channel

Source:
  - app/channel/chatHandler.js, line 188

#### relayGlobalChat(user, flair, highLevel, msg, type, links)

Creates a new chatObject and relays the resulting message to the entire server

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 237

#### relayGlobalChatObject(chat)

Relays an existing chat object to the entire server

##### Parameters:

Name | Type | Description
--- | --- | ---
`chat` | chat | Chat Object representing the message to broadcast throughout the server

Source:
  - app/channel/chatHandler.js, line 245

#### relayGlobalTokeWhisper(msg, links)

Broadcasts toke whisper to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 286

#### relayPrivateChat(socket, user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending a message to (sounds menacing, huh?)
`user` | String | Originating user
`flair` | String | Flair ID to mark chat with
`highLevel` | Number | High Level to mark chat with
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`chan` | String | Channel to broadcast message within
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 215

#### relayPrivateChatObject(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 224

#### relayServerAnnouncement(msg, links)

Broadcasts announcement to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 296

#### relayTokeCallout(msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 268

#### relayTokeWhisper(socket, msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending the whisper to
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 277

#### relayUserChat(socket, msg, type, links)

Relays a chat message from a user to the rest of the channel based on socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 257

#### (async) removeMedia(uuid, socket, chanDB, noScheduling) → {Media}

Removes a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`uuid` | String |  | UUID of item to reschedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`noScheduling` | Boolean | false | Disables schedule timer refresh if true

Source:
  - app/channel/media/queue.js, line 649

##### Returns:

Deleted Media Item

Type
  Media

#### (async) removeRange(start, end, socket, noUnfinished)

Removes range of media items from the queue

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (millis)
`end` | Number |  | End date by JS Epoch (millis)
`socket` | Socket |  | Requesting Socket
`noUnfinished` | Boolean | false | Set to true to include items that may be currently playing

Source:
  - app/channel/media/queue.js, line 492

#### (async) renameChannelPlaylist(socket, data, chanDB)

Renames a channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 855

#### renameChannelPlaylistValidator(socket, data) → {String}

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 170

##### Returns:

returns escaped/trimmed name upon success

Type
  String

#### (async) renameUserPlaylist(socket, data, userDB)

Renames a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 912

#### (async) rescheduleMedia(uuid, start, socket, chanDB)

Reschedules a media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule
`start` | Number | New start time by JS Epoch (Millis)
`socket` | Socket | Requesting Socket
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/queue.js, line 544

#### resetToke()

Resets toke cooldowns early upon authorized request

Source:
  - app/channel/tokebot.js, line 222

#### sanatizeCommand(commandObj) → {Boolean}

Sanatizes and Validates a single user chat message/command

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 82

##### Returns:

false if Command/Message is too long to send

Type
  Boolean

#### (async) scheduleMedia(media, socket, chanDB, force, volatile, startVolatile, saveLate, noSave)

Schedules a Media Item This is a fun method and I think it deserves it's own little explination... Since we're working with a time based schedule, using start epochs as keys for our iterable seemed the best option I don't want to store everything in a sparse array because that *feels* icky, and would probably be a pain in the ass. Maps seem like a good choice, if it wheren't for the issue of keeping them ordered... That's where this comes in. You see if we temporarily store it in a sparse array and convert into a map, we can quickly and easily create a properly sorted schedule map that, out side of adding items, behaves normally. Also a note on preformance: While .forEach ONLY runs through populated items in sparse arrays, many JS implementations run through them in the background, simply skipping them before executing the provided function. Looping through object.keys(arr), however, avoids this entirely, since it ONLY loops through defiened items within the array. No skipped empties for your runtime to worry about. Even more preformance benefits can be had by using a real for loop on the arrays keys, skipping the overhead of forEach entirely. This might seem gross but it completely avoids the computational workload of a sorting algo, especially when you consider that, no matter what, re-ordering the schedule map would've required us to iterate through and rebuild the map anyways... Also it looks like due to implementation limitations, epochs stored as MS are too large for array elements, so we store them there as seconds. This also means that our current implementation will break exactly on unix epoch 4294967295 (Feb 7, 2106 6:28:15 AM UTC) Hopefully javascript arrays will allow for larger lengths by then. If not blame the W3C :P If for some reason they haven't and we're not dead, we could probably implement an object that wraps a 2d array and set/gets it using modulo/devision/multiplication Further Reading: https://stackoverflow.com/questions/59480871/foreach-vs-object-keys-foreach-performance-on-sparse-arrays https://community.appsmith.com/content/blog/dark-side-foreach-why-you-should-think-twice-using-it

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`media` | Media |  | Media item to schedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`force` | Boolean | false | Ignore certain conditions that would prevent scehduling and play the bitch anyways, used for internal function calls
`volatile` | Boolean | false | Prevent DB Writes, used for internal function calls
`startVolatile` | Boolean | false | Runs refreshNextTimer calls without DB writes, used for internal function calls
`saveLate` | Boolean | false | Saves items even if they're about to, or have already started. Used for internal function calls
`noSave` | Boolean | false | Allows function to edit Channel Document, but not save. Used for internal function calls in which the channel document is passed through, but will be saved immediatly after the scheduleMedia() call.

Source:
  - app/channel/media/queue.js, line 819

#### (async) sendChanEmotes(chanDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 220

#### sendChat(commandObj)

Relays chat to channel via parent Chat Handler object

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 153

#### (async) sendClientMetadata(userDB, chanDB)

Sends glut of required initial metadata to the client upon a new connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 141

#### sendMedia(socket)

Send media update to a specific socket or broadcast it to the entire channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1550

#### (async) sendPersonalEmotes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 238

#### (async) sendSiteEmotes()

Send copy of site emotes to the user

Source:
  - app/channel/connectedUser.js, line 208

#### (async) sendUsedTokes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 256

#### (async) setFlair(socket, data)

Handles incoming client request to change flair

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 71

#### (async) setHighLevel(socket, data)

Handles incoming client request to change high level

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 95

#### socketCrawl(cb)

Iterates through all known connections for a given user, running them through a supplied callback function

##### Parameters:

Name | Type | Description
--- | --- | ---
`cb` | function | Callback to call against found sockets for a given user

Source:
  - app/channel/connectedUser.js, line 92

#### splitCommand(commandObj)

Splits raw chat/command data into seperate arrays, one by word-borders and words surrounded by word-borders These arrays are used to handle further command/chat processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 95

#### (async) start(mediaObj, timestamp, volatile)

Kicks off a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`mediaObj` | queuedMedia |  | Media object that's about to play
`timestamp` | Number |  | Media start timestamp in seconds
`volatile` | Boolean | false | Disables DB Transactions

Source:
  - app/channel/media/queue.js, line 998

#### stop(socket)

Stops currently playing media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1414

##### Returns:

returns false if there is nothing to stop

#### (async) stopMedia(socket)

Processes requests to stop currently playing media from client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we received the request from

Source:
  - app/channel/media/queue.js, line 159

#### (async) stopScheduleTimers(noArchive)

Clears and scheduling timers

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`noArchive` | Boolean | true | Disables Archiving

Source:
  - app/channel/media/queue.js, line 383

#### sync()

Sends a syncronization ping out to client Sockets and increments the tracked timestamp by the Synchronization Delta Called auto-magically by the Synchronization Timer

Source:
  - app/channel/media/queue.js, line 1066

#### (async) toggleLock(socket)

Handle client request to (un)lock queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket

Source:
  - app/channel/media/queue.js, line 270

#### tokeProcessor(commandObj) → {Boolean}

Processes toke commands from Command Pre-Processor

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request, passed down from the Command Pre-Processor

Source:
  - app/channel/tokebot.js, line 69

##### Returns:

True if the toke is an invalid toke command (tells Command Pre-Processor to send command as chat)

Type
  Boolean

#### updateFlair(flair)

Set flair for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`flair` | String | Flair string to update user's flair to

Source:
  - app/channel/connectedUser.js, line 273

#### updateHighLevel(highLevel)

Set high level for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`highLevel` | Number | Number to update user's high-level to

Source:
  - app/channel/connectedUser.js, line 284

#### (async) validateSocket(socket) → {Boolean}

Global server-side validation logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 110

##### Returns:

true on success

Type
  Boolean

## exports(io)

Class containing global server-side channel connection management logic

## Constructor

#### new exports(io)

Instantiates object containing global server-side channel conection management logic

##### Parameters:

Name | Type | Description
--- | --- | ---
`io` | Server | Socket.io server instanced passed down from server.js

Source:
  - app/channel/channelManager.js, line 33

### Methods

#### (async) addPersonalEmote(socket, data)

Handles incoming client request to add a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 123

#### (async) addToChannelPlaylist(socket, data, chanDB)

Adds media to channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 434

#### (async) addToPlaylistValidator(socket, URL) → {Array}

Validates client requests to add media to a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`URL` | String | URL String handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 116

##### Returns:

List of media objects which where added

Type
  Array

#### (async) addToUserPlaylist(socket, data, userDB)

Adds media to user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 485

#### (async) asyncFinisher()

This method seems to be a vestage from a bygone era. We should remove it after documenting shit. I would now, but I don't want to break shit in a comment-only commit.

Source:
  - app/channel/tokebot.js, line 194

#### (async) authSocket(socket) → {Mongoose.Document}

Global server-side authorization logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 152

##### Returns:

- Authorized User Document upon success

Type
  Mongoose.Document

#### (async) broadcastChanEmotes(chanDB)

Broadcasts channel emote list to connected users

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/activeChannel.js, line 140

#### (async) broadcastQueue(chanDB)

Broadcasts channel queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1573

#### (async) broadcastSiteEmotes()

Broadcast global emote list

Source:
  - app/channel/channelManager.js, line 297

#### broadcastUserList()

Broadcasts user list to all users

Source:
  - app/channel/activeChannel.js, line 117

#### (async) changeDefaultTitlesChannelPlaylist(socket, data, chanDB)

Changes default titles for a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 968

#### (async) changeDefaultTitlesUserPlaylist(socket, data, userDB)

Changes default titles for a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1008

#### changeDefaultTitlesValidator(data) → {Array}

Validates client requests to change default titles for a given playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 188

##### Returns:

Array of strings containing valid titles from the output

Type
  Array

#### clearChat(user, chan)

Clears chat for a given channel, targets specified user or entire channel if none found/specified.

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | User chats to clear
`chan` | String | Channel to broadcast message within

Source:
  - app/channel/chatHandler.js, line 320

#### cooldown()

Runs every second for 60 seconds after a toke

Source:
  - app/channel/tokebot.js, line 205

#### countdown()

Called each second during the toke. Handles decrementing the timer variable, and countdown end logic.

Source:
  - app/channel/tokebot.js, line 148

#### crawlConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 254

#### (async) createChannelPlaylist(socket, data, chanDB)

Creates a new channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 270

#### createPlaylistValidator(socket, data) → {Object}

Validates client requests to create a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 80

##### Returns:

returns validated titles

Type
  Object

#### (async) createUserPlaylist(socket, data, userDB)

Creates a new user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 319

#### defineListeners(socket)

Define Global Server-Side socket event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 200

#### defineListeners(socket)

Defines global server-side chat relay event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/chatHandler.js, line 49

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/playlistHandler.js, line 47

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/queue.js, line 79

#### (async) deleteChannelPlaylist(socket, data, userDB)

Deletes a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 367

#### (async) deleteChannelPlaylistMedia(socket, data, chanDB)

Deletes media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1048

#### (async) deleteMedia(socket, data)

Processes client requests to delete queued media

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 178

#### (async) deletePersonalEmote(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 158

#### deletePlaylistMediaValidator(socket, data)

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 210

#### (async) deleteRange(socket, data)

Processes request to delete a range of media items from the queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 205

#### (async) deleteUserPlaylist(socket, data, chanDB)

Deletes a Channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 401

#### (async) deleteUserPlaylistMedia(socket, data, userDB)

Deletes media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1097

#### disconnect(reason, type)

Disconnects all sockets for a given user

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`reason` | String |  | Reason for being disconnected
`type` | String | Disconnected | Disconnection Type

Source:
  - app/channel/connectedUser.js, line 129

#### emit(eventName, data)

Emits an event to all known sockets for a given user My brain keeps going back to using dynamic per-user namespaces for this but everytime i look into it I come to the conclusion that it's a bad idea, then I toy with making chans namespaces and using per-user channels for this, but what of gold or mod-only features? or games? No matter what it'd probably end up hacky, as namespaces where meant for splitting app logic not user comms (like rooms). at the end of the day there has to be some penance for decent multi-session handling on-top of a library that doesn't do it. Having to crawl through these sockets is that. Because the other ways seem more gross somehow.

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventName` | String | Event name to emit to client sockets
`data` | Object | Data to emit to client sockets

Source:
  - app/channel/connectedUser.js, line 115

#### (async) end(quiet, noArchive, volatile, chanDB)

End currently playing media

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`quiet` | Boolean | false | Enable to prevent ending the media client-side
`noArchive` | Boolean | false | Enable to prevent ended media from being written to channel archive. Deletes media if Volatile is false
`volatile` | Boolean | false | Enable to prevent DB Transactions
`chanDB` | Mongoose.Document |  | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1099

#### (async) endLivestream(wasPlaying, chanDB)

Ends running Livestream

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1183

#### fromMedia(media, startTime, startTimeStamp) → {queuedMedia}

Creates a queuedMedia object from a media object

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | media | Media object to queue
`startTime` | Number | Start time formatted as a JS Epoch
`startTimeStamp` | Number | Start time stamp in seconds

Source:
  - app/channel/media/queuedMedia.js, line 62

##### Returns:

queuedMedia object created from given media object

Type
  queuedMedia

#### fromMediaArray(mediaList, start)

Converts array of media objects into array of queuedMedia objects

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaList` | Array | Array of media objects to queue
`start` | Number | Start time formatted as JS Epoch

Source:
  - app/channel/media/queuedMedia.js, line 82

##### Returns:

Array of converted queued media objects

#### genUUID()

Generates new unique identifier for queued media

Source:
  - app/channel/media/queuedMedia.js, line 103

#### (async) getActiveChan(socket) → {Object}

Gets active channel from a given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 174

##### Returns:

Object containing users active channel name and channel document object

Type
  Object

#### (async) getChannelPlaylists(socket, chanDB)

Sends channel playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 228

#### getConnectedChannels(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 230

##### Returns:

returns related user info

#### getConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 272

#### getEndTime(fullTime)

return the end time of a given queuedMedia object

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`fullTime` | boolean | false | Overrides early ends

Source:
  - app/channel/media/queuedMedia.js, line 112

##### Returns:

end time of given queuedMedia object

#### getItemAtEpoch(epoch) → {queuedMedia}

Gets a media item by epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis)

Source:
  - app/channel/media/queue.js, line 1471

##### Returns:

found media item

Type
  queuedMedia

#### getItemByUUID(uuid) → {queuedMedia}

Get Scheduled Item by UUID

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule

Source:
  - app/channel/media/queue.js, line 1535

##### Returns:

found item

Type
  queuedMedia

#### getItemsBetweenEpochs(start, end, noUnfinished) → {queuedMedia}

Returns scheduled media between two given datetimes

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (Millis)
`end` | Number |  | End date by JS Epoch (Millis)
`noUnfinished` | Boolean | false | Enable to include currently playing media

Source:
  - app/channel/media/queue.js, line 1446

##### Returns:

Found Media Objects

Type
  queuedMedia

#### getLastItem(epoch)

Gets last item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1490

##### Returns:

Last played item

#### getNextItem(epoch) → {queuedMedia}

Gets next item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1520

##### Returns:

Next item on the schedule

Type
  queuedMedia

#### getSocketInfo(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 220

##### Returns:

returns related user info

#### getStart(start)

Validates start times, and replaces bad ones with 5ms in the future

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | Start time to validate by JS Epoch (millis)

Source:
  - app/channel/media/queue.js, line 407

##### Returns:

Start time as JS Epoch (millis)

#### (async) getUserPlaylists(socket, userDB)

Sends user playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`userDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 248

#### (async) goLive(socket, data)

Handle client request to start an HLS live stream

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 289

#### handleChat(socket, data)

Handles incoming chat messages from client connections

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 62

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections to the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 53

#### (async) handleConnection(socket)

Handles global server-side initialization for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 57

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections from a specific user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/connectedUser.js, line 63

#### handleDisconnect(socket)

Handles server-side initialization for disconnecting from the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 92

#### handleDisconnect(socket, reason)

Global server-side logic for handling disconncted sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check
`reason` | String | Reason for disconnection

Source:
  - app/channel/channelManager.js, line 210

#### (async) handleRawRefresh(mediaObj) → {queuedMedia}

Refreshes expired raw links before media plays

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 978

##### Returns:

passes through Media object with updated link upon success

Type
  queuedMedia

#### kickConnections(user, reason)

Kicks a user from all channels by username

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to kick from the server
`reason` | String | Reason for kick

Source:
  - app/channel/channelManager.js, line 289

#### (async) livestreamOverwriteSchedule(wasPlaying, chanDB)

Overwrites livestream over scheduled media content after it has ended

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1239

#### (async) livestreamPushbackSchedule(wasPlaying, chanDB)

Pushes back any missed content scheduled during Livestream after Livestream has ended.

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1328

#### (async) markLinks(commandObj)

Iterates through links in message and marks them by link type for later use by client-side post-processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 126

#### (async) moveMedia(socket, data)

Processes request to move queued media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 238

#### (async) preSwitch(mediaObj)

Called 10 seconds before media begins to play

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 969

#### (async) prepMessage(commandObj)

Re-creates message string from processed Command Array

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 142

#### (async) prepQueue(chanDB)

Prepares channel queue for network transmission

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1582

##### Returns:

de-hydrated scehdule information

#### (async) preprocess(socket, data)

Ingests a command/chat request from Chat Handler and pre-processes and processes it accordingly

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/commandPreprocessor.js, line 47

#### (async) processServerCommand(commandObj)

Uses the server's Command Processor object to process the chat/command request.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 105

#### (async) queueChannelPlaylist(socket, data, chanDB)

Queues an entire channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 533

#### (async) queueFromChannelPlaylist(socket, data, chanDB)

Queues media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 646

#### queueFromChannelPlaylistValidator(socket, data) → {Number}

Validates client requests to queue media from a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 151

##### Returns:

returns validated start time on success

Type
  Number

#### (async) queueFromUserPlaylist(socket, data, userDB, chanDB)

Queues media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 697

#### (async) queueRandomFromChannelPlaylist(socket, data, chanDB)

Queues random media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 753

#### (async) queueRandomFromUserPlaylist(socket, data, userDB, chanDB)

Queues random media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 801

#### (async) queueURL(socket, data)

Accepts new URL's to queue from the client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the URL from
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 96

#### (async) queueUserPlaylist(socket, data, userDB, chanDB)

Queues an entire user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 587

#### (async) refreshCommands()

Reloads toke commands from DB into RAM-based toke command store

Source:
  - app/channel/tokebot.js, line 59

#### refreshNextTimer(volatile)

Calculates next item to play, and sets timer to play it at it's scheduled start

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`volatile` | Boolean | false | Disables DB Transactions if true

Source:
  - app/channel/media/queue.js, line 442

#### (async) rehydrateQueue(chanDB)

Rehydrates media schedule from DB

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1640

#### relayChannelAnnouncement(msg, links)

Broadcasts announcement to a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 305

#### relayChat(user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given channel

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`chan` | String |  | Channel to broadcast message within
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 179

#### relayChatObject(chan, chat)

Relays an existing chat object to a channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`chan` | String | Channel to broadcast message within
`chat` | chat | Chat Object representing the message to broadcast to the given channel

Source:
  - app/channel/chatHandler.js, line 188

#### relayGlobalChat(user, flair, highLevel, msg, type, links)

Creates a new chatObject and relays the resulting message to the entire server

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 237

#### relayGlobalChatObject(chat)

Relays an existing chat object to the entire server

##### Parameters:

Name | Type | Description
--- | --- | ---
`chat` | chat | Chat Object representing the message to broadcast throughout the server

Source:
  - app/channel/chatHandler.js, line 245

#### relayGlobalTokeWhisper(msg, links)

Broadcasts toke whisper to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 286

#### relayPrivateChat(socket, user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending a message to (sounds menacing, huh?)
`user` | String | Originating user
`flair` | String | Flair ID to mark chat with
`highLevel` | Number | High Level to mark chat with
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`chan` | String | Channel to broadcast message within
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 215

#### relayPrivateChatObject(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 224

#### relayServerAnnouncement(msg, links)

Broadcasts announcement to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 296

#### relayTokeCallout(msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 268

#### relayTokeWhisper(socket, msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending the whisper to
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 277

#### relayUserChat(socket, msg, type, links)

Relays a chat message from a user to the rest of the channel based on socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 257

#### (async) removeMedia(uuid, socket, chanDB, noScheduling) → {Media}

Removes a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`uuid` | String |  | UUID of item to reschedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`noScheduling` | Boolean | false | Disables schedule timer refresh if true

Source:
  - app/channel/media/queue.js, line 649

##### Returns:

Deleted Media Item

Type
  Media

#### (async) removeRange(start, end, socket, noUnfinished)

Removes range of media items from the queue

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (millis)
`end` | Number |  | End date by JS Epoch (millis)
`socket` | Socket |  | Requesting Socket
`noUnfinished` | Boolean | false | Set to true to include items that may be currently playing

Source:
  - app/channel/media/queue.js, line 492

#### (async) renameChannelPlaylist(socket, data, chanDB)

Renames a channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 855

#### renameChannelPlaylistValidator(socket, data) → {String}

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 170

##### Returns:

returns escaped/trimmed name upon success

Type
  String

#### (async) renameUserPlaylist(socket, data, userDB)

Renames a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 912

#### (async) rescheduleMedia(uuid, start, socket, chanDB)

Reschedules a media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule
`start` | Number | New start time by JS Epoch (Millis)
`socket` | Socket | Requesting Socket
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/queue.js, line 544

#### resetToke()

Resets toke cooldowns early upon authorized request

Source:
  - app/channel/tokebot.js, line 222

#### sanatizeCommand(commandObj) → {Boolean}

Sanatizes and Validates a single user chat message/command

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 82

##### Returns:

false if Command/Message is too long to send

Type
  Boolean

#### (async) scheduleMedia(media, socket, chanDB, force, volatile, startVolatile, saveLate, noSave)

Schedules a Media Item This is a fun method and I think it deserves it's own little explination... Since we're working with a time based schedule, using start epochs as keys for our iterable seemed the best option I don't want to store everything in a sparse array because that *feels* icky, and would probably be a pain in the ass. Maps seem like a good choice, if it wheren't for the issue of keeping them ordered... That's where this comes in. You see if we temporarily store it in a sparse array and convert into a map, we can quickly and easily create a properly sorted schedule map that, out side of adding items, behaves normally. Also a note on preformance: While .forEach ONLY runs through populated items in sparse arrays, many JS implementations run through them in the background, simply skipping them before executing the provided function. Looping through object.keys(arr), however, avoids this entirely, since it ONLY loops through defiened items within the array. No skipped empties for your runtime to worry about. Even more preformance benefits can be had by using a real for loop on the arrays keys, skipping the overhead of forEach entirely. This might seem gross but it completely avoids the computational workload of a sorting algo, especially when you consider that, no matter what, re-ordering the schedule map would've required us to iterate through and rebuild the map anyways... Also it looks like due to implementation limitations, epochs stored as MS are too large for array elements, so we store them there as seconds. This also means that our current implementation will break exactly on unix epoch 4294967295 (Feb 7, 2106 6:28:15 AM UTC) Hopefully javascript arrays will allow for larger lengths by then. If not blame the W3C :P If for some reason they haven't and we're not dead, we could probably implement an object that wraps a 2d array and set/gets it using modulo/devision/multiplication Further Reading: https://stackoverflow.com/questions/59480871/foreach-vs-object-keys-foreach-performance-on-sparse-arrays https://community.appsmith.com/content/blog/dark-side-foreach-why-you-should-think-twice-using-it

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`media` | Media |  | Media item to schedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`force` | Boolean | false | Ignore certain conditions that would prevent scehduling and play the bitch anyways, used for internal function calls
`volatile` | Boolean | false | Prevent DB Writes, used for internal function calls
`startVolatile` | Boolean | false | Runs refreshNextTimer calls without DB writes, used for internal function calls
`saveLate` | Boolean | false | Saves items even if they're about to, or have already started. Used for internal function calls
`noSave` | Boolean | false | Allows function to edit Channel Document, but not save. Used for internal function calls in which the channel document is passed through, but will be saved immediatly after the scheduleMedia() call.

Source:
  - app/channel/media/queue.js, line 819

#### (async) sendChanEmotes(chanDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 220

#### sendChat(commandObj)

Relays chat to channel via parent Chat Handler object

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 153

#### (async) sendClientMetadata(userDB, chanDB)

Sends glut of required initial metadata to the client upon a new connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 141

#### sendMedia(socket)

Send media update to a specific socket or broadcast it to the entire channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1550

#### (async) sendPersonalEmotes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 238

#### (async) sendSiteEmotes()

Send copy of site emotes to the user

Source:
  - app/channel/connectedUser.js, line 208

#### (async) sendUsedTokes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 256

#### (async) setFlair(socket, data)

Handles incoming client request to change flair

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 71

#### (async) setHighLevel(socket, data)

Handles incoming client request to change high level

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 95

#### socketCrawl(cb)

Iterates through all known connections for a given user, running them through a supplied callback function

##### Parameters:

Name | Type | Description
--- | --- | ---
`cb` | function | Callback to call against found sockets for a given user

Source:
  - app/channel/connectedUser.js, line 92

#### splitCommand(commandObj)

Splits raw chat/command data into seperate arrays, one by word-borders and words surrounded by word-borders These arrays are used to handle further command/chat processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 95

#### (async) start(mediaObj, timestamp, volatile)

Kicks off a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`mediaObj` | queuedMedia |  | Media object that's about to play
`timestamp` | Number |  | Media start timestamp in seconds
`volatile` | Boolean | false | Disables DB Transactions

Source:
  - app/channel/media/queue.js, line 998

#### stop(socket)

Stops currently playing media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1414

##### Returns:

returns false if there is nothing to stop

#### (async) stopMedia(socket)

Processes requests to stop currently playing media from client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we received the request from

Source:
  - app/channel/media/queue.js, line 159

#### (async) stopScheduleTimers(noArchive)

Clears and scheduling timers

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`noArchive` | Boolean | true | Disables Archiving

Source:
  - app/channel/media/queue.js, line 383

#### sync()

Sends a syncronization ping out to client Sockets and increments the tracked timestamp by the Synchronization Delta Called auto-magically by the Synchronization Timer

Source:
  - app/channel/media/queue.js, line 1066

#### (async) toggleLock(socket)

Handle client request to (un)lock queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket

Source:
  - app/channel/media/queue.js, line 270

#### tokeProcessor(commandObj) → {Boolean}

Processes toke commands from Command Pre-Processor

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request, passed down from the Command Pre-Processor

Source:
  - app/channel/tokebot.js, line 69

##### Returns:

True if the toke is an invalid toke command (tells Command Pre-Processor to send command as chat)

Type
  Boolean

#### updateFlair(flair)

Set flair for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`flair` | String | Flair string to update user's flair to

Source:
  - app/channel/connectedUser.js, line 273

#### updateHighLevel(highLevel)

Set high level for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`highLevel` | Number | Number to update user's high-level to

Source:
  - app/channel/connectedUser.js, line 284

#### (async) validateSocket(socket) → {Boolean}

Global server-side validation logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 110

##### Returns:

true on success

Type
  Boolean

## exports(server)

Class containing global server-side chat relay logic

## Constructor

#### new exports(server)

Instantiates a chatHandler object

##### Parameters:

Name | Type | Description
--- | --- | ---
`server` | channelManager | Parent Server Object

Source:
  - app/channel/chatHandler.js, line 31

### Methods

#### (async) addPersonalEmote(socket, data)

Handles incoming client request to add a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 123

#### (async) addToChannelPlaylist(socket, data, chanDB)

Adds media to channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 434

#### (async) addToPlaylistValidator(socket, URL) → {Array}

Validates client requests to add media to a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`URL` | String | URL String handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 116

##### Returns:

List of media objects which where added

Type
  Array

#### (async) addToUserPlaylist(socket, data, userDB)

Adds media to user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 485

#### (async) asyncFinisher()

This method seems to be a vestage from a bygone era. We should remove it after documenting shit. I would now, but I don't want to break shit in a comment-only commit.

Source:
  - app/channel/tokebot.js, line 194

#### (async) authSocket(socket) → {Mongoose.Document}

Global server-side authorization logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 152

##### Returns:

- Authorized User Document upon success

Type
  Mongoose.Document

#### (async) broadcastChanEmotes(chanDB)

Broadcasts channel emote list to connected users

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/activeChannel.js, line 140

#### (async) broadcastQueue(chanDB)

Broadcasts channel queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1573

#### (async) broadcastSiteEmotes()

Broadcast global emote list

Source:
  - app/channel/channelManager.js, line 297

#### broadcastUserList()

Broadcasts user list to all users

Source:
  - app/channel/activeChannel.js, line 117

#### (async) changeDefaultTitlesChannelPlaylist(socket, data, chanDB)

Changes default titles for a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 968

#### (async) changeDefaultTitlesUserPlaylist(socket, data, userDB)

Changes default titles for a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1008

#### changeDefaultTitlesValidator(data) → {Array}

Validates client requests to change default titles for a given playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 188

##### Returns:

Array of strings containing valid titles from the output

Type
  Array

#### clearChat(user, chan)

Clears chat for a given channel, targets specified user or entire channel if none found/specified.

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | User chats to clear
`chan` | String | Channel to broadcast message within

Source:
  - app/channel/chatHandler.js, line 320

#### cooldown()

Runs every second for 60 seconds after a toke

Source:
  - app/channel/tokebot.js, line 205

#### countdown()

Called each second during the toke. Handles decrementing the timer variable, and countdown end logic.

Source:
  - app/channel/tokebot.js, line 148

#### crawlConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 254

#### (async) createChannelPlaylist(socket, data, chanDB)

Creates a new channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 270

#### createPlaylistValidator(socket, data) → {Object}

Validates client requests to create a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 80

##### Returns:

returns validated titles

Type
  Object

#### (async) createUserPlaylist(socket, data, userDB)

Creates a new user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 319

#### defineListeners(socket)

Define Global Server-Side socket event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 200

#### defineListeners(socket)

Defines global server-side chat relay event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/chatHandler.js, line 49

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/playlistHandler.js, line 47

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/queue.js, line 79

#### (async) deleteChannelPlaylist(socket, data, userDB)

Deletes a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 367

#### (async) deleteChannelPlaylistMedia(socket, data, chanDB)

Deletes media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1048

#### (async) deleteMedia(socket, data)

Processes client requests to delete queued media

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 178

#### (async) deletePersonalEmote(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 158

#### deletePlaylistMediaValidator(socket, data)

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 210

#### (async) deleteRange(socket, data)

Processes request to delete a range of media items from the queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 205

#### (async) deleteUserPlaylist(socket, data, chanDB)

Deletes a Channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 401

#### (async) deleteUserPlaylistMedia(socket, data, userDB)

Deletes media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1097

#### disconnect(reason, type)

Disconnects all sockets for a given user

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`reason` | String |  | Reason for being disconnected
`type` | String | Disconnected | Disconnection Type

Source:
  - app/channel/connectedUser.js, line 129

#### emit(eventName, data)

Emits an event to all known sockets for a given user My brain keeps going back to using dynamic per-user namespaces for this but everytime i look into it I come to the conclusion that it's a bad idea, then I toy with making chans namespaces and using per-user channels for this, but what of gold or mod-only features? or games? No matter what it'd probably end up hacky, as namespaces where meant for splitting app logic not user comms (like rooms). at the end of the day there has to be some penance for decent multi-session handling on-top of a library that doesn't do it. Having to crawl through these sockets is that. Because the other ways seem more gross somehow.

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventName` | String | Event name to emit to client sockets
`data` | Object | Data to emit to client sockets

Source:
  - app/channel/connectedUser.js, line 115

#### (async) end(quiet, noArchive, volatile, chanDB)

End currently playing media

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`quiet` | Boolean | false | Enable to prevent ending the media client-side
`noArchive` | Boolean | false | Enable to prevent ended media from being written to channel archive. Deletes media if Volatile is false
`volatile` | Boolean | false | Enable to prevent DB Transactions
`chanDB` | Mongoose.Document |  | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1099

#### (async) endLivestream(wasPlaying, chanDB)

Ends running Livestream

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1183

#### fromMedia(media, startTime, startTimeStamp) → {queuedMedia}

Creates a queuedMedia object from a media object

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | media | Media object to queue
`startTime` | Number | Start time formatted as a JS Epoch
`startTimeStamp` | Number | Start time stamp in seconds

Source:
  - app/channel/media/queuedMedia.js, line 62

##### Returns:

queuedMedia object created from given media object

Type
  queuedMedia

#### fromMediaArray(mediaList, start)

Converts array of media objects into array of queuedMedia objects

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaList` | Array | Array of media objects to queue
`start` | Number | Start time formatted as JS Epoch

Source:
  - app/channel/media/queuedMedia.js, line 82

##### Returns:

Array of converted queued media objects

#### genUUID()

Generates new unique identifier for queued media

Source:
  - app/channel/media/queuedMedia.js, line 103

#### (async) getActiveChan(socket) → {Object}

Gets active channel from a given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 174

##### Returns:

Object containing users active channel name and channel document object

Type
  Object

#### (async) getChannelPlaylists(socket, chanDB)

Sends channel playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 228

#### getConnectedChannels(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 230

##### Returns:

returns related user info

#### getConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 272

#### getEndTime(fullTime)

return the end time of a given queuedMedia object

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`fullTime` | boolean | false | Overrides early ends

Source:
  - app/channel/media/queuedMedia.js, line 112

##### Returns:

end time of given queuedMedia object

#### getItemAtEpoch(epoch) → {queuedMedia}

Gets a media item by epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis)

Source:
  - app/channel/media/queue.js, line 1471

##### Returns:

found media item

Type
  queuedMedia

#### getItemByUUID(uuid) → {queuedMedia}

Get Scheduled Item by UUID

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule

Source:
  - app/channel/media/queue.js, line 1535

##### Returns:

found item

Type
  queuedMedia

#### getItemsBetweenEpochs(start, end, noUnfinished) → {queuedMedia}

Returns scheduled media between two given datetimes

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (Millis)
`end` | Number |  | End date by JS Epoch (Millis)
`noUnfinished` | Boolean | false | Enable to include currently playing media

Source:
  - app/channel/media/queue.js, line 1446

##### Returns:

Found Media Objects

Type
  queuedMedia

#### getLastItem(epoch)

Gets last item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1490

##### Returns:

Last played item

#### getNextItem(epoch) → {queuedMedia}

Gets next item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1520

##### Returns:

Next item on the schedule

Type
  queuedMedia

#### getSocketInfo(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 220

##### Returns:

returns related user info

#### getStart(start)

Validates start times, and replaces bad ones with 5ms in the future

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | Start time to validate by JS Epoch (millis)

Source:
  - app/channel/media/queue.js, line 407

##### Returns:

Start time as JS Epoch (millis)

#### (async) getUserPlaylists(socket, userDB)

Sends user playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`userDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 248

#### (async) goLive(socket, data)

Handle client request to start an HLS live stream

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 289

#### handleChat(socket, data)

Handles incoming chat messages from client connections

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 62

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections to the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 53

#### (async) handleConnection(socket)

Handles global server-side initialization for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 57

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections from a specific user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/connectedUser.js, line 63

#### handleDisconnect(socket)

Handles server-side initialization for disconnecting from the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 92

#### handleDisconnect(socket, reason)

Global server-side logic for handling disconncted sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check
`reason` | String | Reason for disconnection

Source:
  - app/channel/channelManager.js, line 210

#### (async) handleRawRefresh(mediaObj) → {queuedMedia}

Refreshes expired raw links before media plays

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 978

##### Returns:

passes through Media object with updated link upon success

Type
  queuedMedia

#### kickConnections(user, reason)

Kicks a user from all channels by username

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to kick from the server
`reason` | String | Reason for kick

Source:
  - app/channel/channelManager.js, line 289

#### (async) livestreamOverwriteSchedule(wasPlaying, chanDB)

Overwrites livestream over scheduled media content after it has ended

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1239

#### (async) livestreamPushbackSchedule(wasPlaying, chanDB)

Pushes back any missed content scheduled during Livestream after Livestream has ended.

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1328

#### (async) markLinks(commandObj)

Iterates through links in message and marks them by link type for later use by client-side post-processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 126

#### (async) moveMedia(socket, data)

Processes request to move queued media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 238

#### (async) preSwitch(mediaObj)

Called 10 seconds before media begins to play

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 969

#### (async) prepMessage(commandObj)

Re-creates message string from processed Command Array

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 142

#### (async) prepQueue(chanDB)

Prepares channel queue for network transmission

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1582

##### Returns:

de-hydrated scehdule information

#### (async) preprocess(socket, data)

Ingests a command/chat request from Chat Handler and pre-processes and processes it accordingly

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/commandPreprocessor.js, line 47

#### (async) processServerCommand(commandObj)

Uses the server's Command Processor object to process the chat/command request.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 105

#### (async) queueChannelPlaylist(socket, data, chanDB)

Queues an entire channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 533

#### (async) queueFromChannelPlaylist(socket, data, chanDB)

Queues media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 646

#### queueFromChannelPlaylistValidator(socket, data) → {Number}

Validates client requests to queue media from a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 151

##### Returns:

returns validated start time on success

Type
  Number

#### (async) queueFromUserPlaylist(socket, data, userDB, chanDB)

Queues media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 697

#### (async) queueRandomFromChannelPlaylist(socket, data, chanDB)

Queues random media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 753

#### (async) queueRandomFromUserPlaylist(socket, data, userDB, chanDB)

Queues random media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 801

#### (async) queueURL(socket, data)

Accepts new URL's to queue from the client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the URL from
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 96

#### (async) queueUserPlaylist(socket, data, userDB, chanDB)

Queues an entire user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 587

#### (async) refreshCommands()

Reloads toke commands from DB into RAM-based toke command store

Source:
  - app/channel/tokebot.js, line 59

#### refreshNextTimer(volatile)

Calculates next item to play, and sets timer to play it at it's scheduled start

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`volatile` | Boolean | false | Disables DB Transactions if true

Source:
  - app/channel/media/queue.js, line 442

#### (async) rehydrateQueue(chanDB)

Rehydrates media schedule from DB

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1640

#### relayChannelAnnouncement(msg, links)

Broadcasts announcement to a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 305

#### relayChat(user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given channel

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`chan` | String |  | Channel to broadcast message within
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 179

#### relayChatObject(chan, chat)

Relays an existing chat object to a channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`chan` | String | Channel to broadcast message within
`chat` | chat | Chat Object representing the message to broadcast to the given channel

Source:
  - app/channel/chatHandler.js, line 188

#### relayGlobalChat(user, flair, highLevel, msg, type, links)

Creates a new chatObject and relays the resulting message to the entire server

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 237

#### relayGlobalChatObject(chat)

Relays an existing chat object to the entire server

##### Parameters:

Name | Type | Description
--- | --- | ---
`chat` | chat | Chat Object representing the message to broadcast throughout the server

Source:
  - app/channel/chatHandler.js, line 245

#### relayGlobalTokeWhisper(msg, links)

Broadcasts toke whisper to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 286

#### relayPrivateChat(socket, user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending a message to (sounds menacing, huh?)
`user` | String | Originating user
`flair` | String | Flair ID to mark chat with
`highLevel` | Number | High Level to mark chat with
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`chan` | String | Channel to broadcast message within
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 215

#### relayPrivateChatObject(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 224

#### relayServerAnnouncement(msg, links)

Broadcasts announcement to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 296

#### relayTokeCallout(msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 268

#### relayTokeWhisper(socket, msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending the whisper to
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 277

#### relayUserChat(socket, msg, type, links)

Relays a chat message from a user to the rest of the channel based on socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 257

#### (async) removeMedia(uuid, socket, chanDB, noScheduling) → {Media}

Removes a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`uuid` | String |  | UUID of item to reschedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`noScheduling` | Boolean | false | Disables schedule timer refresh if true

Source:
  - app/channel/media/queue.js, line 649

##### Returns:

Deleted Media Item

Type
  Media

#### (async) removeRange(start, end, socket, noUnfinished)

Removes range of media items from the queue

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (millis)
`end` | Number |  | End date by JS Epoch (millis)
`socket` | Socket |  | Requesting Socket
`noUnfinished` | Boolean | false | Set to true to include items that may be currently playing

Source:
  - app/channel/media/queue.js, line 492

#### (async) renameChannelPlaylist(socket, data, chanDB)

Renames a channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 855

#### renameChannelPlaylistValidator(socket, data) → {String}

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 170

##### Returns:

returns escaped/trimmed name upon success

Type
  String

#### (async) renameUserPlaylist(socket, data, userDB)

Renames a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 912

#### (async) rescheduleMedia(uuid, start, socket, chanDB)

Reschedules a media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule
`start` | Number | New start time by JS Epoch (Millis)
`socket` | Socket | Requesting Socket
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/queue.js, line 544

#### resetToke()

Resets toke cooldowns early upon authorized request

Source:
  - app/channel/tokebot.js, line 222

#### sanatizeCommand(commandObj) → {Boolean}

Sanatizes and Validates a single user chat message/command

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 82

##### Returns:

false if Command/Message is too long to send

Type
  Boolean

#### (async) scheduleMedia(media, socket, chanDB, force, volatile, startVolatile, saveLate, noSave)

Schedules a Media Item This is a fun method and I think it deserves it's own little explination... Since we're working with a time based schedule, using start epochs as keys for our iterable seemed the best option I don't want to store everything in a sparse array because that *feels* icky, and would probably be a pain in the ass. Maps seem like a good choice, if it wheren't for the issue of keeping them ordered... That's where this comes in. You see if we temporarily store it in a sparse array and convert into a map, we can quickly and easily create a properly sorted schedule map that, out side of adding items, behaves normally. Also a note on preformance: While .forEach ONLY runs through populated items in sparse arrays, many JS implementations run through them in the background, simply skipping them before executing the provided function. Looping through object.keys(arr), however, avoids this entirely, since it ONLY loops through defiened items within the array. No skipped empties for your runtime to worry about. Even more preformance benefits can be had by using a real for loop on the arrays keys, skipping the overhead of forEach entirely. This might seem gross but it completely avoids the computational workload of a sorting algo, especially when you consider that, no matter what, re-ordering the schedule map would've required us to iterate through and rebuild the map anyways... Also it looks like due to implementation limitations, epochs stored as MS are too large for array elements, so we store them there as seconds. This also means that our current implementation will break exactly on unix epoch 4294967295 (Feb 7, 2106 6:28:15 AM UTC) Hopefully javascript arrays will allow for larger lengths by then. If not blame the W3C :P If for some reason they haven't and we're not dead, we could probably implement an object that wraps a 2d array and set/gets it using modulo/devision/multiplication Further Reading: https://stackoverflow.com/questions/59480871/foreach-vs-object-keys-foreach-performance-on-sparse-arrays https://community.appsmith.com/content/blog/dark-side-foreach-why-you-should-think-twice-using-it

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`media` | Media |  | Media item to schedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`force` | Boolean | false | Ignore certain conditions that would prevent scehduling and play the bitch anyways, used for internal function calls
`volatile` | Boolean | false | Prevent DB Writes, used for internal function calls
`startVolatile` | Boolean | false | Runs refreshNextTimer calls without DB writes, used for internal function calls
`saveLate` | Boolean | false | Saves items even if they're about to, or have already started. Used for internal function calls
`noSave` | Boolean | false | Allows function to edit Channel Document, but not save. Used for internal function calls in which the channel document is passed through, but will be saved immediatly after the scheduleMedia() call.

Source:
  - app/channel/media/queue.js, line 819

#### (async) sendChanEmotes(chanDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 220

#### sendChat(commandObj)

Relays chat to channel via parent Chat Handler object

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 153

#### (async) sendClientMetadata(userDB, chanDB)

Sends glut of required initial metadata to the client upon a new connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 141

#### sendMedia(socket)

Send media update to a specific socket or broadcast it to the entire channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1550

#### (async) sendPersonalEmotes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 238

#### (async) sendSiteEmotes()

Send copy of site emotes to the user

Source:
  - app/channel/connectedUser.js, line 208

#### (async) sendUsedTokes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 256

#### (async) setFlair(socket, data)

Handles incoming client request to change flair

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 71

#### (async) setHighLevel(socket, data)

Handles incoming client request to change high level

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 95

#### socketCrawl(cb)

Iterates through all known connections for a given user, running them through a supplied callback function

##### Parameters:

Name | Type | Description
--- | --- | ---
`cb` | function | Callback to call against found sockets for a given user

Source:
  - app/channel/connectedUser.js, line 92

#### splitCommand(commandObj)

Splits raw chat/command data into seperate arrays, one by word-borders and words surrounded by word-borders These arrays are used to handle further command/chat processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 95

#### (async) start(mediaObj, timestamp, volatile)

Kicks off a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`mediaObj` | queuedMedia |  | Media object that's about to play
`timestamp` | Number |  | Media start timestamp in seconds
`volatile` | Boolean | false | Disables DB Transactions

Source:
  - app/channel/media/queue.js, line 998

#### stop(socket)

Stops currently playing media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1414

##### Returns:

returns false if there is nothing to stop

#### (async) stopMedia(socket)

Processes requests to stop currently playing media from client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we received the request from

Source:
  - app/channel/media/queue.js, line 159

#### (async) stopScheduleTimers(noArchive)

Clears and scheduling timers

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`noArchive` | Boolean | true | Disables Archiving

Source:
  - app/channel/media/queue.js, line 383

#### sync()

Sends a syncronization ping out to client Sockets and increments the tracked timestamp by the Synchronization Delta Called auto-magically by the Synchronization Timer

Source:
  - app/channel/media/queue.js, line 1066

#### (async) toggleLock(socket)

Handle client request to (un)lock queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket

Source:
  - app/channel/media/queue.js, line 270

#### tokeProcessor(commandObj) → {Boolean}

Processes toke commands from Command Pre-Processor

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request, passed down from the Command Pre-Processor

Source:
  - app/channel/tokebot.js, line 69

##### Returns:

True if the toke is an invalid toke command (tells Command Pre-Processor to send command as chat)

Type
  Boolean

#### updateFlair(flair)

Set flair for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`flair` | String | Flair string to update user's flair to

Source:
  - app/channel/connectedUser.js, line 273

#### updateHighLevel(highLevel)

Set high level for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`highLevel` | Number | Number to update user's high-level to

Source:
  - app/channel/connectedUser.js, line 284

#### (async) validateSocket(socket) → {Boolean}

Global server-side validation logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 110

##### Returns:

true on success

Type
  Boolean

## exports(server, chatHandler)

Class containing global server-side chat/command pre-processing logic

## Constructor

#### new exports(server, chatHandler)

Instantiates a commandPreprocessor object

##### Parameters:

Name | Type | Description
--- | --- | ---
`server` | channelManager | Parent Server Object
`chatHandler` | chatHandler | Parent Chat Handler Object

Source:
  - app/channel/commandPreprocessor.js, line 29

### Methods

#### (async) addPersonalEmote(socket, data)

Handles incoming client request to add a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 123

#### (async) addToChannelPlaylist(socket, data, chanDB)

Adds media to channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 434

#### (async) addToPlaylistValidator(socket, URL) → {Array}

Validates client requests to add media to a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`URL` | String | URL String handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 116

##### Returns:

List of media objects which where added

Type
  Array

#### (async) addToUserPlaylist(socket, data, userDB)

Adds media to user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 485

#### (async) asyncFinisher()

This method seems to be a vestage from a bygone era. We should remove it after documenting shit. I would now, but I don't want to break shit in a comment-only commit.

Source:
  - app/channel/tokebot.js, line 194

#### (async) authSocket(socket) → {Mongoose.Document}

Global server-side authorization logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 152

##### Returns:

- Authorized User Document upon success

Type
  Mongoose.Document

#### (async) broadcastChanEmotes(chanDB)

Broadcasts channel emote list to connected users

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/activeChannel.js, line 140

#### (async) broadcastQueue(chanDB)

Broadcasts channel queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1573

#### (async) broadcastSiteEmotes()

Broadcast global emote list

Source:
  - app/channel/channelManager.js, line 297

#### broadcastUserList()

Broadcasts user list to all users

Source:
  - app/channel/activeChannel.js, line 117

#### (async) changeDefaultTitlesChannelPlaylist(socket, data, chanDB)

Changes default titles for a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 968

#### (async) changeDefaultTitlesUserPlaylist(socket, data, userDB)

Changes default titles for a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1008

#### changeDefaultTitlesValidator(data) → {Array}

Validates client requests to change default titles for a given playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 188

##### Returns:

Array of strings containing valid titles from the output

Type
  Array

#### clearChat(user, chan)

Clears chat for a given channel, targets specified user or entire channel if none found/specified.

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | User chats to clear
`chan` | String | Channel to broadcast message within

Source:
  - app/channel/chatHandler.js, line 320

#### cooldown()

Runs every second for 60 seconds after a toke

Source:
  - app/channel/tokebot.js, line 205

#### countdown()

Called each second during the toke. Handles decrementing the timer variable, and countdown end logic.

Source:
  - app/channel/tokebot.js, line 148

#### crawlConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 254

#### (async) createChannelPlaylist(socket, data, chanDB)

Creates a new channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 270

#### createPlaylistValidator(socket, data) → {Object}

Validates client requests to create a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 80

##### Returns:

returns validated titles

Type
  Object

#### (async) createUserPlaylist(socket, data, userDB)

Creates a new user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 319

#### defineListeners(socket)

Define Global Server-Side socket event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 200

#### defineListeners(socket)

Defines global server-side chat relay event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/chatHandler.js, line 49

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/playlistHandler.js, line 47

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/queue.js, line 79

#### (async) deleteChannelPlaylist(socket, data, userDB)

Deletes a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 367

#### (async) deleteChannelPlaylistMedia(socket, data, chanDB)

Deletes media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1048

#### (async) deleteMedia(socket, data)

Processes client requests to delete queued media

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 178

#### (async) deletePersonalEmote(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 158

#### deletePlaylistMediaValidator(socket, data)

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 210

#### (async) deleteRange(socket, data)

Processes request to delete a range of media items from the queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 205

#### (async) deleteUserPlaylist(socket, data, chanDB)

Deletes a Channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 401

#### (async) deleteUserPlaylistMedia(socket, data, userDB)

Deletes media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1097

#### disconnect(reason, type)

Disconnects all sockets for a given user

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`reason` | String |  | Reason for being disconnected
`type` | String | Disconnected | Disconnection Type

Source:
  - app/channel/connectedUser.js, line 129

#### emit(eventName, data)

Emits an event to all known sockets for a given user My brain keeps going back to using dynamic per-user namespaces for this but everytime i look into it I come to the conclusion that it's a bad idea, then I toy with making chans namespaces and using per-user channels for this, but what of gold or mod-only features? or games? No matter what it'd probably end up hacky, as namespaces where meant for splitting app logic not user comms (like rooms). at the end of the day there has to be some penance for decent multi-session handling on-top of a library that doesn't do it. Having to crawl through these sockets is that. Because the other ways seem more gross somehow.

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventName` | String | Event name to emit to client sockets
`data` | Object | Data to emit to client sockets

Source:
  - app/channel/connectedUser.js, line 115

#### (async) end(quiet, noArchive, volatile, chanDB)

End currently playing media

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`quiet` | Boolean | false | Enable to prevent ending the media client-side
`noArchive` | Boolean | false | Enable to prevent ended media from being written to channel archive. Deletes media if Volatile is false
`volatile` | Boolean | false | Enable to prevent DB Transactions
`chanDB` | Mongoose.Document |  | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1099

#### (async) endLivestream(wasPlaying, chanDB)

Ends running Livestream

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1183

#### fromMedia(media, startTime, startTimeStamp) → {queuedMedia}

Creates a queuedMedia object from a media object

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | media | Media object to queue
`startTime` | Number | Start time formatted as a JS Epoch
`startTimeStamp` | Number | Start time stamp in seconds

Source:
  - app/channel/media/queuedMedia.js, line 62

##### Returns:

queuedMedia object created from given media object

Type
  queuedMedia

#### fromMediaArray(mediaList, start)

Converts array of media objects into array of queuedMedia objects

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaList` | Array | Array of media objects to queue
`start` | Number | Start time formatted as JS Epoch

Source:
  - app/channel/media/queuedMedia.js, line 82

##### Returns:

Array of converted queued media objects

#### genUUID()

Generates new unique identifier for queued media

Source:
  - app/channel/media/queuedMedia.js, line 103

#### (async) getActiveChan(socket) → {Object}

Gets active channel from a given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 174

##### Returns:

Object containing users active channel name and channel document object

Type
  Object

#### (async) getChannelPlaylists(socket, chanDB)

Sends channel playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 228

#### getConnectedChannels(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 230

##### Returns:

returns related user info

#### getConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 272

#### getEndTime(fullTime)

return the end time of a given queuedMedia object

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`fullTime` | boolean | false | Overrides early ends

Source:
  - app/channel/media/queuedMedia.js, line 112

##### Returns:

end time of given queuedMedia object

#### getItemAtEpoch(epoch) → {queuedMedia}

Gets a media item by epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis)

Source:
  - app/channel/media/queue.js, line 1471

##### Returns:

found media item

Type
  queuedMedia

#### getItemByUUID(uuid) → {queuedMedia}

Get Scheduled Item by UUID

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule

Source:
  - app/channel/media/queue.js, line 1535

##### Returns:

found item

Type
  queuedMedia

#### getItemsBetweenEpochs(start, end, noUnfinished) → {queuedMedia}

Returns scheduled media between two given datetimes

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (Millis)
`end` | Number |  | End date by JS Epoch (Millis)
`noUnfinished` | Boolean | false | Enable to include currently playing media

Source:
  - app/channel/media/queue.js, line 1446

##### Returns:

Found Media Objects

Type
  queuedMedia

#### getLastItem(epoch)

Gets last item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1490

##### Returns:

Last played item

#### getNextItem(epoch) → {queuedMedia}

Gets next item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1520

##### Returns:

Next item on the schedule

Type
  queuedMedia

#### getSocketInfo(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 220

##### Returns:

returns related user info

#### getStart(start)

Validates start times, and replaces bad ones with 5ms in the future

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | Start time to validate by JS Epoch (millis)

Source:
  - app/channel/media/queue.js, line 407

##### Returns:

Start time as JS Epoch (millis)

#### (async) getUserPlaylists(socket, userDB)

Sends user playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`userDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 248

#### (async) goLive(socket, data)

Handle client request to start an HLS live stream

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 289

#### handleChat(socket, data)

Handles incoming chat messages from client connections

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 62

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections to the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 53

#### (async) handleConnection(socket)

Handles global server-side initialization for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 57

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections from a specific user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/connectedUser.js, line 63

#### handleDisconnect(socket)

Handles server-side initialization for disconnecting from the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 92

#### handleDisconnect(socket, reason)

Global server-side logic for handling disconncted sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check
`reason` | String | Reason for disconnection

Source:
  - app/channel/channelManager.js, line 210

#### (async) handleRawRefresh(mediaObj) → {queuedMedia}

Refreshes expired raw links before media plays

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 978

##### Returns:

passes through Media object with updated link upon success

Type
  queuedMedia

#### kickConnections(user, reason)

Kicks a user from all channels by username

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to kick from the server
`reason` | String | Reason for kick

Source:
  - app/channel/channelManager.js, line 289

#### (async) livestreamOverwriteSchedule(wasPlaying, chanDB)

Overwrites livestream over scheduled media content after it has ended

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1239

#### (async) livestreamPushbackSchedule(wasPlaying, chanDB)

Pushes back any missed content scheduled during Livestream after Livestream has ended.

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1328

#### (async) markLinks(commandObj)

Iterates through links in message and marks them by link type for later use by client-side post-processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 126

#### (async) moveMedia(socket, data)

Processes request to move queued media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 238

#### (async) preSwitch(mediaObj)

Called 10 seconds before media begins to play

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 969

#### (async) prepMessage(commandObj)

Re-creates message string from processed Command Array

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 142

#### (async) prepQueue(chanDB)

Prepares channel queue for network transmission

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1582

##### Returns:

de-hydrated scehdule information

#### (async) preprocess(socket, data)

Ingests a command/chat request from Chat Handler and pre-processes and processes it accordingly

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/commandPreprocessor.js, line 47

#### (async) processServerCommand(commandObj)

Uses the server's Command Processor object to process the chat/command request.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 105

#### (async) queueChannelPlaylist(socket, data, chanDB)

Queues an entire channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 533

#### (async) queueFromChannelPlaylist(socket, data, chanDB)

Queues media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 646

#### queueFromChannelPlaylistValidator(socket, data) → {Number}

Validates client requests to queue media from a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 151

##### Returns:

returns validated start time on success

Type
  Number

#### (async) queueFromUserPlaylist(socket, data, userDB, chanDB)

Queues media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 697

#### (async) queueRandomFromChannelPlaylist(socket, data, chanDB)

Queues random media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 753

#### (async) queueRandomFromUserPlaylist(socket, data, userDB, chanDB)

Queues random media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 801

#### (async) queueURL(socket, data)

Accepts new URL's to queue from the client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the URL from
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 96

#### (async) queueUserPlaylist(socket, data, userDB, chanDB)

Queues an entire user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 587

#### (async) refreshCommands()

Reloads toke commands from DB into RAM-based toke command store

Source:
  - app/channel/tokebot.js, line 59

#### refreshNextTimer(volatile)

Calculates next item to play, and sets timer to play it at it's scheduled start

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`volatile` | Boolean | false | Disables DB Transactions if true

Source:
  - app/channel/media/queue.js, line 442

#### (async) rehydrateQueue(chanDB)

Rehydrates media schedule from DB

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1640

#### relayChannelAnnouncement(msg, links)

Broadcasts announcement to a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 305

#### relayChat(user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given channel

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`chan` | String |  | Channel to broadcast message within
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 179

#### relayChatObject(chan, chat)

Relays an existing chat object to a channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`chan` | String | Channel to broadcast message within
`chat` | chat | Chat Object representing the message to broadcast to the given channel

Source:
  - app/channel/chatHandler.js, line 188

#### relayGlobalChat(user, flair, highLevel, msg, type, links)

Creates a new chatObject and relays the resulting message to the entire server

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 237

#### relayGlobalChatObject(chat)

Relays an existing chat object to the entire server

##### Parameters:

Name | Type | Description
--- | --- | ---
`chat` | chat | Chat Object representing the message to broadcast throughout the server

Source:
  - app/channel/chatHandler.js, line 245

#### relayGlobalTokeWhisper(msg, links)

Broadcasts toke whisper to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 286

#### relayPrivateChat(socket, user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending a message to (sounds menacing, huh?)
`user` | String | Originating user
`flair` | String | Flair ID to mark chat with
`highLevel` | Number | High Level to mark chat with
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`chan` | String | Channel to broadcast message within
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 215

#### relayPrivateChatObject(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 224

#### relayServerAnnouncement(msg, links)

Broadcasts announcement to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 296

#### relayTokeCallout(msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 268

#### relayTokeWhisper(socket, msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending the whisper to
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 277

#### relayUserChat(socket, msg, type, links)

Relays a chat message from a user to the rest of the channel based on socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 257

#### (async) removeMedia(uuid, socket, chanDB, noScheduling) → {Media}

Removes a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`uuid` | String |  | UUID of item to reschedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`noScheduling` | Boolean | false | Disables schedule timer refresh if true

Source:
  - app/channel/media/queue.js, line 649

##### Returns:

Deleted Media Item

Type
  Media

#### (async) removeRange(start, end, socket, noUnfinished)

Removes range of media items from the queue

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (millis)
`end` | Number |  | End date by JS Epoch (millis)
`socket` | Socket |  | Requesting Socket
`noUnfinished` | Boolean | false | Set to true to include items that may be currently playing

Source:
  - app/channel/media/queue.js, line 492

#### (async) renameChannelPlaylist(socket, data, chanDB)

Renames a channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 855

#### renameChannelPlaylistValidator(socket, data) → {String}

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 170

##### Returns:

returns escaped/trimmed name upon success

Type
  String

#### (async) renameUserPlaylist(socket, data, userDB)

Renames a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 912

#### (async) rescheduleMedia(uuid, start, socket, chanDB)

Reschedules a media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule
`start` | Number | New start time by JS Epoch (Millis)
`socket` | Socket | Requesting Socket
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/queue.js, line 544

#### resetToke()

Resets toke cooldowns early upon authorized request

Source:
  - app/channel/tokebot.js, line 222

#### sanatizeCommand(commandObj) → {Boolean}

Sanatizes and Validates a single user chat message/command

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 82

##### Returns:

false if Command/Message is too long to send

Type
  Boolean

#### (async) scheduleMedia(media, socket, chanDB, force, volatile, startVolatile, saveLate, noSave)

Schedules a Media Item This is a fun method and I think it deserves it's own little explination... Since we're working with a time based schedule, using start epochs as keys for our iterable seemed the best option I don't want to store everything in a sparse array because that *feels* icky, and would probably be a pain in the ass. Maps seem like a good choice, if it wheren't for the issue of keeping them ordered... That's where this comes in. You see if we temporarily store it in a sparse array and convert into a map, we can quickly and easily create a properly sorted schedule map that, out side of adding items, behaves normally. Also a note on preformance: While .forEach ONLY runs through populated items in sparse arrays, many JS implementations run through them in the background, simply skipping them before executing the provided function. Looping through object.keys(arr), however, avoids this entirely, since it ONLY loops through defiened items within the array. No skipped empties for your runtime to worry about. Even more preformance benefits can be had by using a real for loop on the arrays keys, skipping the overhead of forEach entirely. This might seem gross but it completely avoids the computational workload of a sorting algo, especially when you consider that, no matter what, re-ordering the schedule map would've required us to iterate through and rebuild the map anyways... Also it looks like due to implementation limitations, epochs stored as MS are too large for array elements, so we store them there as seconds. This also means that our current implementation will break exactly on unix epoch 4294967295 (Feb 7, 2106 6:28:15 AM UTC) Hopefully javascript arrays will allow for larger lengths by then. If not blame the W3C :P If for some reason they haven't and we're not dead, we could probably implement an object that wraps a 2d array and set/gets it using modulo/devision/multiplication Further Reading: https://stackoverflow.com/questions/59480871/foreach-vs-object-keys-foreach-performance-on-sparse-arrays https://community.appsmith.com/content/blog/dark-side-foreach-why-you-should-think-twice-using-it

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`media` | Media |  | Media item to schedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`force` | Boolean | false | Ignore certain conditions that would prevent scehduling and play the bitch anyways, used for internal function calls
`volatile` | Boolean | false | Prevent DB Writes, used for internal function calls
`startVolatile` | Boolean | false | Runs refreshNextTimer calls without DB writes, used for internal function calls
`saveLate` | Boolean | false | Saves items even if they're about to, or have already started. Used for internal function calls
`noSave` | Boolean | false | Allows function to edit Channel Document, but not save. Used for internal function calls in which the channel document is passed through, but will be saved immediatly after the scheduleMedia() call.

Source:
  - app/channel/media/queue.js, line 819

#### (async) sendChanEmotes(chanDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 220

#### sendChat(commandObj)

Relays chat to channel via parent Chat Handler object

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 153

#### (async) sendClientMetadata(userDB, chanDB)

Sends glut of required initial metadata to the client upon a new connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 141

#### sendMedia(socket)

Send media update to a specific socket or broadcast it to the entire channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1550

#### (async) sendPersonalEmotes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 238

#### (async) sendSiteEmotes()

Send copy of site emotes to the user

Source:
  - app/channel/connectedUser.js, line 208

#### (async) sendUsedTokes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 256

#### (async) setFlair(socket, data)

Handles incoming client request to change flair

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 71

#### (async) setHighLevel(socket, data)

Handles incoming client request to change high level

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 95

#### socketCrawl(cb)

Iterates through all known connections for a given user, running them through a supplied callback function

##### Parameters:

Name | Type | Description
--- | --- | ---
`cb` | function | Callback to call against found sockets for a given user

Source:
  - app/channel/connectedUser.js, line 92

#### splitCommand(commandObj)

Splits raw chat/command data into seperate arrays, one by word-borders and words surrounded by word-borders These arrays are used to handle further command/chat processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 95

#### (async) start(mediaObj, timestamp, volatile)

Kicks off a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`mediaObj` | queuedMedia |  | Media object that's about to play
`timestamp` | Number |  | Media start timestamp in seconds
`volatile` | Boolean | false | Disables DB Transactions

Source:
  - app/channel/media/queue.js, line 998

#### stop(socket)

Stops currently playing media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1414

##### Returns:

returns false if there is nothing to stop

#### (async) stopMedia(socket)

Processes requests to stop currently playing media from client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we received the request from

Source:
  - app/channel/media/queue.js, line 159

#### (async) stopScheduleTimers(noArchive)

Clears and scheduling timers

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`noArchive` | Boolean | true | Disables Archiving

Source:
  - app/channel/media/queue.js, line 383

#### sync()

Sends a syncronization ping out to client Sockets and increments the tracked timestamp by the Synchronization Delta Called auto-magically by the Synchronization Timer

Source:
  - app/channel/media/queue.js, line 1066

#### (async) toggleLock(socket)

Handle client request to (un)lock queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket

Source:
  - app/channel/media/queue.js, line 270

#### tokeProcessor(commandObj) → {Boolean}

Processes toke commands from Command Pre-Processor

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request, passed down from the Command Pre-Processor

Source:
  - app/channel/tokebot.js, line 69

##### Returns:

True if the toke is an invalid toke command (tells Command Pre-Processor to send command as chat)

Type
  Boolean

#### updateFlair(flair)

Set flair for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`flair` | String | Flair string to update user's flair to

Source:
  - app/channel/connectedUser.js, line 273

#### updateHighLevel(highLevel)

Set high level for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`highLevel` | Number | Number to update user's high-level to

Source:
  - app/channel/connectedUser.js, line 284

#### (async) validateSocket(socket) → {Boolean}

Global server-side validation logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 110

##### Returns:

true on success

Type
  Boolean

## exports(userDB, chanRank, channel, socket)

Class representing a single user connected to a channel

## Constructor

#### new exports(userDB, chanRank, channel, socket)

Instantiates a connectedUser object

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User document to re-hydrate user from
`chanRank` | PemissionModel.chanRank | Enum representing user channel rank
`channel` | String | Channel the user is connecting to
`socket` | Socket | Socket associated with the users connection

Source:
  - app/channel/connectedUser.js, line 28

### Methods

#### (async) addPersonalEmote(socket, data)

Handles incoming client request to add a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 123

#### (async) addToChannelPlaylist(socket, data, chanDB)

Adds media to channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 434

#### (async) addToPlaylistValidator(socket, URL) → {Array}

Validates client requests to add media to a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`URL` | String | URL String handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 116

##### Returns:

List of media objects which where added

Type
  Array

#### (async) addToUserPlaylist(socket, data, userDB)

Adds media to user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 485

#### (async) asyncFinisher()

This method seems to be a vestage from a bygone era. We should remove it after documenting shit. I would now, but I don't want to break shit in a comment-only commit.

Source:
  - app/channel/tokebot.js, line 194

#### (async) authSocket(socket) → {Mongoose.Document}

Global server-side authorization logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 152

##### Returns:

- Authorized User Document upon success

Type
  Mongoose.Document

#### (async) broadcastChanEmotes(chanDB)

Broadcasts channel emote list to connected users

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/activeChannel.js, line 140

#### (async) broadcastQueue(chanDB)

Broadcasts channel queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1573

#### (async) broadcastSiteEmotes()

Broadcast global emote list

Source:
  - app/channel/channelManager.js, line 297

#### broadcastUserList()

Broadcasts user list to all users

Source:
  - app/channel/activeChannel.js, line 117

#### (async) changeDefaultTitlesChannelPlaylist(socket, data, chanDB)

Changes default titles for a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 968

#### (async) changeDefaultTitlesUserPlaylist(socket, data, userDB)

Changes default titles for a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1008

#### changeDefaultTitlesValidator(data) → {Array}

Validates client requests to change default titles for a given playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 188

##### Returns:

Array of strings containing valid titles from the output

Type
  Array

#### clearChat(user, chan)

Clears chat for a given channel, targets specified user or entire channel if none found/specified.

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | User chats to clear
`chan` | String | Channel to broadcast message within

Source:
  - app/channel/chatHandler.js, line 320

#### cooldown()

Runs every second for 60 seconds after a toke

Source:
  - app/channel/tokebot.js, line 205

#### countdown()

Called each second during the toke. Handles decrementing the timer variable, and countdown end logic.

Source:
  - app/channel/tokebot.js, line 148

#### crawlConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 254

#### (async) createChannelPlaylist(socket, data, chanDB)

Creates a new channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 270

#### createPlaylistValidator(socket, data) → {Object}

Validates client requests to create a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 80

##### Returns:

returns validated titles

Type
  Object

#### (async) createUserPlaylist(socket, data, userDB)

Creates a new user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 319

#### defineListeners(socket)

Define Global Server-Side socket event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 200

#### defineListeners(socket)

Defines global server-side chat relay event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/chatHandler.js, line 49

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/playlistHandler.js, line 47

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/queue.js, line 79

#### (async) deleteChannelPlaylist(socket, data, userDB)

Deletes a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 367

#### (async) deleteChannelPlaylistMedia(socket, data, chanDB)

Deletes media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1048

#### (async) deleteMedia(socket, data)

Processes client requests to delete queued media

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 178

#### (async) deletePersonalEmote(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 158

#### deletePlaylistMediaValidator(socket, data)

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 210

#### (async) deleteRange(socket, data)

Processes request to delete a range of media items from the queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 205

#### (async) deleteUserPlaylist(socket, data, chanDB)

Deletes a Channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 401

#### (async) deleteUserPlaylistMedia(socket, data, userDB)

Deletes media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1097

#### disconnect(reason, type)

Disconnects all sockets for a given user

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`reason` | String |  | Reason for being disconnected
`type` | String | Disconnected | Disconnection Type

Source:
  - app/channel/connectedUser.js, line 129

#### emit(eventName, data)

Emits an event to all known sockets for a given user My brain keeps going back to using dynamic per-user namespaces for this but everytime i look into it I come to the conclusion that it's a bad idea, then I toy with making chans namespaces and using per-user channels for this, but what of gold or mod-only features? or games? No matter what it'd probably end up hacky, as namespaces where meant for splitting app logic not user comms (like rooms). at the end of the day there has to be some penance for decent multi-session handling on-top of a library that doesn't do it. Having to crawl through these sockets is that. Because the other ways seem more gross somehow.

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventName` | String | Event name to emit to client sockets
`data` | Object | Data to emit to client sockets

Source:
  - app/channel/connectedUser.js, line 115

#### (async) end(quiet, noArchive, volatile, chanDB)

End currently playing media

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`quiet` | Boolean | false | Enable to prevent ending the media client-side
`noArchive` | Boolean | false | Enable to prevent ended media from being written to channel archive. Deletes media if Volatile is false
`volatile` | Boolean | false | Enable to prevent DB Transactions
`chanDB` | Mongoose.Document |  | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1099

#### (async) endLivestream(wasPlaying, chanDB)

Ends running Livestream

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1183

#### fromMedia(media, startTime, startTimeStamp) → {queuedMedia}

Creates a queuedMedia object from a media object

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | media | Media object to queue
`startTime` | Number | Start time formatted as a JS Epoch
`startTimeStamp` | Number | Start time stamp in seconds

Source:
  - app/channel/media/queuedMedia.js, line 62

##### Returns:

queuedMedia object created from given media object

Type
  queuedMedia

#### fromMediaArray(mediaList, start)

Converts array of media objects into array of queuedMedia objects

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaList` | Array | Array of media objects to queue
`start` | Number | Start time formatted as JS Epoch

Source:
  - app/channel/media/queuedMedia.js, line 82

##### Returns:

Array of converted queued media objects

#### genUUID()

Generates new unique identifier for queued media

Source:
  - app/channel/media/queuedMedia.js, line 103

#### (async) getActiveChan(socket) → {Object}

Gets active channel from a given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 174

##### Returns:

Object containing users active channel name and channel document object

Type
  Object

#### (async) getChannelPlaylists(socket, chanDB)

Sends channel playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 228

#### getConnectedChannels(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 230

##### Returns:

returns related user info

#### getConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 272

#### getEndTime(fullTime)

return the end time of a given queuedMedia object

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`fullTime` | boolean | false | Overrides early ends

Source:
  - app/channel/media/queuedMedia.js, line 112

##### Returns:

end time of given queuedMedia object

#### getItemAtEpoch(epoch) → {queuedMedia}

Gets a media item by epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis)

Source:
  - app/channel/media/queue.js, line 1471

##### Returns:

found media item

Type
  queuedMedia

#### getItemByUUID(uuid) → {queuedMedia}

Get Scheduled Item by UUID

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule

Source:
  - app/channel/media/queue.js, line 1535

##### Returns:

found item

Type
  queuedMedia

#### getItemsBetweenEpochs(start, end, noUnfinished) → {queuedMedia}

Returns scheduled media between two given datetimes

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (Millis)
`end` | Number |  | End date by JS Epoch (Millis)
`noUnfinished` | Boolean | false | Enable to include currently playing media

Source:
  - app/channel/media/queue.js, line 1446

##### Returns:

Found Media Objects

Type
  queuedMedia

#### getLastItem(epoch)

Gets last item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1490

##### Returns:

Last played item

#### getNextItem(epoch) → {queuedMedia}

Gets next item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1520

##### Returns:

Next item on the schedule

Type
  queuedMedia

#### getSocketInfo(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 220

##### Returns:

returns related user info

#### getStart(start)

Validates start times, and replaces bad ones with 5ms in the future

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | Start time to validate by JS Epoch (millis)

Source:
  - app/channel/media/queue.js, line 407

##### Returns:

Start time as JS Epoch (millis)

#### (async) getUserPlaylists(socket, userDB)

Sends user playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`userDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 248

#### (async) goLive(socket, data)

Handle client request to start an HLS live stream

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 289

#### handleChat(socket, data)

Handles incoming chat messages from client connections

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 62

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections to the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 53

#### (async) handleConnection(socket)

Handles global server-side initialization for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 57

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections from a specific user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/connectedUser.js, line 63

#### handleDisconnect(socket)

Handles server-side initialization for disconnecting from the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 92

#### handleDisconnect(socket, reason)

Global server-side logic for handling disconncted sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check
`reason` | String | Reason for disconnection

Source:
  - app/channel/channelManager.js, line 210

#### (async) handleRawRefresh(mediaObj) → {queuedMedia}

Refreshes expired raw links before media plays

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 978

##### Returns:

passes through Media object with updated link upon success

Type
  queuedMedia

#### kickConnections(user, reason)

Kicks a user from all channels by username

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to kick from the server
`reason` | String | Reason for kick

Source:
  - app/channel/channelManager.js, line 289

#### (async) livestreamOverwriteSchedule(wasPlaying, chanDB)

Overwrites livestream over scheduled media content after it has ended

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1239

#### (async) livestreamPushbackSchedule(wasPlaying, chanDB)

Pushes back any missed content scheduled during Livestream after Livestream has ended.

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1328

#### (async) markLinks(commandObj)

Iterates through links in message and marks them by link type for later use by client-side post-processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 126

#### (async) moveMedia(socket, data)

Processes request to move queued media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 238

#### (async) preSwitch(mediaObj)

Called 10 seconds before media begins to play

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 969

#### (async) prepMessage(commandObj)

Re-creates message string from processed Command Array

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 142

#### (async) prepQueue(chanDB)

Prepares channel queue for network transmission

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1582

##### Returns:

de-hydrated scehdule information

#### (async) preprocess(socket, data)

Ingests a command/chat request from Chat Handler and pre-processes and processes it accordingly

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/commandPreprocessor.js, line 47

#### (async) processServerCommand(commandObj)

Uses the server's Command Processor object to process the chat/command request.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 105

#### (async) queueChannelPlaylist(socket, data, chanDB)

Queues an entire channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 533

#### (async) queueFromChannelPlaylist(socket, data, chanDB)

Queues media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 646

#### queueFromChannelPlaylistValidator(socket, data) → {Number}

Validates client requests to queue media from a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 151

##### Returns:

returns validated start time on success

Type
  Number

#### (async) queueFromUserPlaylist(socket, data, userDB, chanDB)

Queues media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 697

#### (async) queueRandomFromChannelPlaylist(socket, data, chanDB)

Queues random media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 753

#### (async) queueRandomFromUserPlaylist(socket, data, userDB, chanDB)

Queues random media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 801

#### (async) queueURL(socket, data)

Accepts new URL's to queue from the client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the URL from
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 96

#### (async) queueUserPlaylist(socket, data, userDB, chanDB)

Queues an entire user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 587

#### (async) refreshCommands()

Reloads toke commands from DB into RAM-based toke command store

Source:
  - app/channel/tokebot.js, line 59

#### refreshNextTimer(volatile)

Calculates next item to play, and sets timer to play it at it's scheduled start

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`volatile` | Boolean | false | Disables DB Transactions if true

Source:
  - app/channel/media/queue.js, line 442

#### (async) rehydrateQueue(chanDB)

Rehydrates media schedule from DB

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1640

#### relayChannelAnnouncement(msg, links)

Broadcasts announcement to a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 305

#### relayChat(user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given channel

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`chan` | String |  | Channel to broadcast message within
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 179

#### relayChatObject(chan, chat)

Relays an existing chat object to a channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`chan` | String | Channel to broadcast message within
`chat` | chat | Chat Object representing the message to broadcast to the given channel

Source:
  - app/channel/chatHandler.js, line 188

#### relayGlobalChat(user, flair, highLevel, msg, type, links)

Creates a new chatObject and relays the resulting message to the entire server

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 237

#### relayGlobalChatObject(chat)

Relays an existing chat object to the entire server

##### Parameters:

Name | Type | Description
--- | --- | ---
`chat` | chat | Chat Object representing the message to broadcast throughout the server

Source:
  - app/channel/chatHandler.js, line 245

#### relayGlobalTokeWhisper(msg, links)

Broadcasts toke whisper to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 286

#### relayPrivateChat(socket, user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending a message to (sounds menacing, huh?)
`user` | String | Originating user
`flair` | String | Flair ID to mark chat with
`highLevel` | Number | High Level to mark chat with
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`chan` | String | Channel to broadcast message within
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 215

#### relayPrivateChatObject(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 224

#### relayServerAnnouncement(msg, links)

Broadcasts announcement to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 296

#### relayTokeCallout(msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 268

#### relayTokeWhisper(socket, msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending the whisper to
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 277

#### relayUserChat(socket, msg, type, links)

Relays a chat message from a user to the rest of the channel based on socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 257

#### (async) removeMedia(uuid, socket, chanDB, noScheduling) → {Media}

Removes a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`uuid` | String |  | UUID of item to reschedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`noScheduling` | Boolean | false | Disables schedule timer refresh if true

Source:
  - app/channel/media/queue.js, line 649

##### Returns:

Deleted Media Item

Type
  Media

#### (async) removeRange(start, end, socket, noUnfinished)

Removes range of media items from the queue

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (millis)
`end` | Number |  | End date by JS Epoch (millis)
`socket` | Socket |  | Requesting Socket
`noUnfinished` | Boolean | false | Set to true to include items that may be currently playing

Source:
  - app/channel/media/queue.js, line 492

#### (async) renameChannelPlaylist(socket, data, chanDB)

Renames a channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 855

#### renameChannelPlaylistValidator(socket, data) → {String}

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 170

##### Returns:

returns escaped/trimmed name upon success

Type
  String

#### (async) renameUserPlaylist(socket, data, userDB)

Renames a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 912

#### (async) rescheduleMedia(uuid, start, socket, chanDB)

Reschedules a media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule
`start` | Number | New start time by JS Epoch (Millis)
`socket` | Socket | Requesting Socket
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/queue.js, line 544

#### resetToke()

Resets toke cooldowns early upon authorized request

Source:
  - app/channel/tokebot.js, line 222

#### sanatizeCommand(commandObj) → {Boolean}

Sanatizes and Validates a single user chat message/command

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 82

##### Returns:

false if Command/Message is too long to send

Type
  Boolean

#### (async) scheduleMedia(media, socket, chanDB, force, volatile, startVolatile, saveLate, noSave)

Schedules a Media Item This is a fun method and I think it deserves it's own little explination... Since we're working with a time based schedule, using start epochs as keys for our iterable seemed the best option I don't want to store everything in a sparse array because that *feels* icky, and would probably be a pain in the ass. Maps seem like a good choice, if it wheren't for the issue of keeping them ordered... That's where this comes in. You see if we temporarily store it in a sparse array and convert into a map, we can quickly and easily create a properly sorted schedule map that, out side of adding items, behaves normally. Also a note on preformance: While .forEach ONLY runs through populated items in sparse arrays, many JS implementations run through them in the background, simply skipping them before executing the provided function. Looping through object.keys(arr), however, avoids this entirely, since it ONLY loops through defiened items within the array. No skipped empties for your runtime to worry about. Even more preformance benefits can be had by using a real for loop on the arrays keys, skipping the overhead of forEach entirely. This might seem gross but it completely avoids the computational workload of a sorting algo, especially when you consider that, no matter what, re-ordering the schedule map would've required us to iterate through and rebuild the map anyways... Also it looks like due to implementation limitations, epochs stored as MS are too large for array elements, so we store them there as seconds. This also means that our current implementation will break exactly on unix epoch 4294967295 (Feb 7, 2106 6:28:15 AM UTC) Hopefully javascript arrays will allow for larger lengths by then. If not blame the W3C :P If for some reason they haven't and we're not dead, we could probably implement an object that wraps a 2d array and set/gets it using modulo/devision/multiplication Further Reading: https://stackoverflow.com/questions/59480871/foreach-vs-object-keys-foreach-performance-on-sparse-arrays https://community.appsmith.com/content/blog/dark-side-foreach-why-you-should-think-twice-using-it

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`media` | Media |  | Media item to schedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`force` | Boolean | false | Ignore certain conditions that would prevent scehduling and play the bitch anyways, used for internal function calls
`volatile` | Boolean | false | Prevent DB Writes, used for internal function calls
`startVolatile` | Boolean | false | Runs refreshNextTimer calls without DB writes, used for internal function calls
`saveLate` | Boolean | false | Saves items even if they're about to, or have already started. Used for internal function calls
`noSave` | Boolean | false | Allows function to edit Channel Document, but not save. Used for internal function calls in which the channel document is passed through, but will be saved immediatly after the scheduleMedia() call.

Source:
  - app/channel/media/queue.js, line 819

#### (async) sendChanEmotes(chanDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 220

#### sendChat(commandObj)

Relays chat to channel via parent Chat Handler object

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 153

#### (async) sendClientMetadata(userDB, chanDB)

Sends glut of required initial metadata to the client upon a new connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 141

#### sendMedia(socket)

Send media update to a specific socket or broadcast it to the entire channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1550

#### (async) sendPersonalEmotes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 238

#### (async) sendSiteEmotes()

Send copy of site emotes to the user

Source:
  - app/channel/connectedUser.js, line 208

#### (async) sendUsedTokes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 256

#### (async) setFlair(socket, data)

Handles incoming client request to change flair

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 71

#### (async) setHighLevel(socket, data)

Handles incoming client request to change high level

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 95

#### socketCrawl(cb)

Iterates through all known connections for a given user, running them through a supplied callback function

##### Parameters:

Name | Type | Description
--- | --- | ---
`cb` | function | Callback to call against found sockets for a given user

Source:
  - app/channel/connectedUser.js, line 92

#### splitCommand(commandObj)

Splits raw chat/command data into seperate arrays, one by word-borders and words surrounded by word-borders These arrays are used to handle further command/chat processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 95

#### (async) start(mediaObj, timestamp, volatile)

Kicks off a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`mediaObj` | queuedMedia |  | Media object that's about to play
`timestamp` | Number |  | Media start timestamp in seconds
`volatile` | Boolean | false | Disables DB Transactions

Source:
  - app/channel/media/queue.js, line 998

#### stop(socket)

Stops currently playing media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1414

##### Returns:

returns false if there is nothing to stop

#### (async) stopMedia(socket)

Processes requests to stop currently playing media from client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we received the request from

Source:
  - app/channel/media/queue.js, line 159

#### (async) stopScheduleTimers(noArchive)

Clears and scheduling timers

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`noArchive` | Boolean | true | Disables Archiving

Source:
  - app/channel/media/queue.js, line 383

#### sync()

Sends a syncronization ping out to client Sockets and increments the tracked timestamp by the Synchronization Delta Called auto-magically by the Synchronization Timer

Source:
  - app/channel/media/queue.js, line 1066

#### (async) toggleLock(socket)

Handle client request to (un)lock queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket

Source:
  - app/channel/media/queue.js, line 270

#### tokeProcessor(commandObj) → {Boolean}

Processes toke commands from Command Pre-Processor

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request, passed down from the Command Pre-Processor

Source:
  - app/channel/tokebot.js, line 69

##### Returns:

True if the toke is an invalid toke command (tells Command Pre-Processor to send command as chat)

Type
  Boolean

#### updateFlair(flair)

Set flair for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`flair` | String | Flair string to update user's flair to

Source:
  - app/channel/connectedUser.js, line 273

#### updateHighLevel(highLevel)

Set high level for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`highLevel` | Number | Number to update user's high-level to

Source:
  - app/channel/connectedUser.js, line 284

#### (async) validateSocket(socket) → {Boolean}

Global server-side validation logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 110

##### Returns:

true on success

Type
  Boolean

## exports(title, fileName, url, id, type, duration, rawLink)

Object representing a piece of media

## Constructor

#### new exports(title, fileName, url, id, type, duration, rawLink)

Creates a new media object from scraped information

##### Parameters:

Name | Type | Description
--- | --- | ---
`title` | String | Chosen title of media
`fileName` | String | Original filename/title of media provided by source
`url` | String | Original URL to file
`id` | String | Video ID from source (IE: youtube watch code/archive.org file path)
`type` | String | Original video source
`duration` | Number | Length of media in seconds
`rawLink` | String | URL to raw file copy of media, not applicable to all sources

Source:
  - app/channel/media/media.js, line 20

### Methods

#### (async) addPersonalEmote(socket, data)

Handles incoming client request to add a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 123

#### (async) addToChannelPlaylist(socket, data, chanDB)

Adds media to channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 434

#### (async) addToPlaylistValidator(socket, URL) → {Array}

Validates client requests to add media to a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`URL` | String | URL String handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 116

##### Returns:

List of media objects which where added

Type
  Array

#### (async) addToUserPlaylist(socket, data, userDB)

Adds media to user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 485

#### (async) asyncFinisher()

This method seems to be a vestage from a bygone era. We should remove it after documenting shit. I would now, but I don't want to break shit in a comment-only commit.

Source:
  - app/channel/tokebot.js, line 194

#### (async) authSocket(socket) → {Mongoose.Document}

Global server-side authorization logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 152

##### Returns:

- Authorized User Document upon success

Type
  Mongoose.Document

#### (async) broadcastChanEmotes(chanDB)

Broadcasts channel emote list to connected users

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/activeChannel.js, line 140

#### (async) broadcastQueue(chanDB)

Broadcasts channel queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1573

#### (async) broadcastSiteEmotes()

Broadcast global emote list

Source:
  - app/channel/channelManager.js, line 297

#### broadcastUserList()

Broadcasts user list to all users

Source:
  - app/channel/activeChannel.js, line 117

#### (async) changeDefaultTitlesChannelPlaylist(socket, data, chanDB)

Changes default titles for a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 968

#### (async) changeDefaultTitlesUserPlaylist(socket, data, userDB)

Changes default titles for a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1008

#### changeDefaultTitlesValidator(data) → {Array}

Validates client requests to change default titles for a given playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 188

##### Returns:

Array of strings containing valid titles from the output

Type
  Array

#### clearChat(user, chan)

Clears chat for a given channel, targets specified user or entire channel if none found/specified.

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | User chats to clear
`chan` | String | Channel to broadcast message within

Source:
  - app/channel/chatHandler.js, line 320

#### cooldown()

Runs every second for 60 seconds after a toke

Source:
  - app/channel/tokebot.js, line 205

#### countdown()

Called each second during the toke. Handles decrementing the timer variable, and countdown end logic.

Source:
  - app/channel/tokebot.js, line 148

#### crawlConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 254

#### (async) createChannelPlaylist(socket, data, chanDB)

Creates a new channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 270

#### createPlaylistValidator(socket, data) → {Object}

Validates client requests to create a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 80

##### Returns:

returns validated titles

Type
  Object

#### (async) createUserPlaylist(socket, data, userDB)

Creates a new user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 319

#### defineListeners(socket)

Define Global Server-Side socket event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 200

#### defineListeners(socket)

Defines global server-side chat relay event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/chatHandler.js, line 49

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/playlistHandler.js, line 47

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/queue.js, line 79

#### (async) deleteChannelPlaylist(socket, data, userDB)

Deletes a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 367

#### (async) deleteChannelPlaylistMedia(socket, data, chanDB)

Deletes media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1048

#### (async) deleteMedia(socket, data)

Processes client requests to delete queued media

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 178

#### (async) deletePersonalEmote(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 158

#### deletePlaylistMediaValidator(socket, data)

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 210

#### (async) deleteRange(socket, data)

Processes request to delete a range of media items from the queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 205

#### (async) deleteUserPlaylist(socket, data, chanDB)

Deletes a Channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 401

#### (async) deleteUserPlaylistMedia(socket, data, userDB)

Deletes media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1097

#### disconnect(reason, type)

Disconnects all sockets for a given user

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`reason` | String |  | Reason for being disconnected
`type` | String | Disconnected | Disconnection Type

Source:
  - app/channel/connectedUser.js, line 129

#### emit(eventName, data)

Emits an event to all known sockets for a given user My brain keeps going back to using dynamic per-user namespaces for this but everytime i look into it I come to the conclusion that it's a bad idea, then I toy with making chans namespaces and using per-user channels for this, but what of gold or mod-only features? or games? No matter what it'd probably end up hacky, as namespaces where meant for splitting app logic not user comms (like rooms). at the end of the day there has to be some penance for decent multi-session handling on-top of a library that doesn't do it. Having to crawl through these sockets is that. Because the other ways seem more gross somehow.

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventName` | String | Event name to emit to client sockets
`data` | Object | Data to emit to client sockets

Source:
  - app/channel/connectedUser.js, line 115

#### (async) end(quiet, noArchive, volatile, chanDB)

End currently playing media

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`quiet` | Boolean | false | Enable to prevent ending the media client-side
`noArchive` | Boolean | false | Enable to prevent ended media from being written to channel archive. Deletes media if Volatile is false
`volatile` | Boolean | false | Enable to prevent DB Transactions
`chanDB` | Mongoose.Document |  | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1099

#### (async) endLivestream(wasPlaying, chanDB)

Ends running Livestream

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1183

#### fromMedia(media, startTime, startTimeStamp) → {queuedMedia}

Creates a queuedMedia object from a media object

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | media | Media object to queue
`startTime` | Number | Start time formatted as a JS Epoch
`startTimeStamp` | Number | Start time stamp in seconds

Source:
  - app/channel/media/queuedMedia.js, line 62

##### Returns:

queuedMedia object created from given media object

Type
  queuedMedia

#### fromMediaArray(mediaList, start)

Converts array of media objects into array of queuedMedia objects

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaList` | Array | Array of media objects to queue
`start` | Number | Start time formatted as JS Epoch

Source:
  - app/channel/media/queuedMedia.js, line 82

##### Returns:

Array of converted queued media objects

#### genUUID()

Generates new unique identifier for queued media

Source:
  - app/channel/media/queuedMedia.js, line 103

#### (async) getActiveChan(socket) → {Object}

Gets active channel from a given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 174

##### Returns:

Object containing users active channel name and channel document object

Type
  Object

#### (async) getChannelPlaylists(socket, chanDB)

Sends channel playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 228

#### getConnectedChannels(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 230

##### Returns:

returns related user info

#### getConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 272

#### getEndTime(fullTime)

return the end time of a given queuedMedia object

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`fullTime` | boolean | false | Overrides early ends

Source:
  - app/channel/media/queuedMedia.js, line 112

##### Returns:

end time of given queuedMedia object

#### getItemAtEpoch(epoch) → {queuedMedia}

Gets a media item by epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis)

Source:
  - app/channel/media/queue.js, line 1471

##### Returns:

found media item

Type
  queuedMedia

#### getItemByUUID(uuid) → {queuedMedia}

Get Scheduled Item by UUID

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule

Source:
  - app/channel/media/queue.js, line 1535

##### Returns:

found item

Type
  queuedMedia

#### getItemsBetweenEpochs(start, end, noUnfinished) → {queuedMedia}

Returns scheduled media between two given datetimes

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (Millis)
`end` | Number |  | End date by JS Epoch (Millis)
`noUnfinished` | Boolean | false | Enable to include currently playing media

Source:
  - app/channel/media/queue.js, line 1446

##### Returns:

Found Media Objects

Type
  queuedMedia

#### getLastItem(epoch)

Gets last item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1490

##### Returns:

Last played item

#### getNextItem(epoch) → {queuedMedia}

Gets next item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1520

##### Returns:

Next item on the schedule

Type
  queuedMedia

#### getSocketInfo(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 220

##### Returns:

returns related user info

#### getStart(start)

Validates start times, and replaces bad ones with 5ms in the future

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | Start time to validate by JS Epoch (millis)

Source:
  - app/channel/media/queue.js, line 407

##### Returns:

Start time as JS Epoch (millis)

#### (async) getUserPlaylists(socket, userDB)

Sends user playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`userDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 248

#### (async) goLive(socket, data)

Handle client request to start an HLS live stream

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 289

#### handleChat(socket, data)

Handles incoming chat messages from client connections

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 62

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections to the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 53

#### (async) handleConnection(socket)

Handles global server-side initialization for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 57

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections from a specific user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/connectedUser.js, line 63

#### handleDisconnect(socket)

Handles server-side initialization for disconnecting from the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 92

#### handleDisconnect(socket, reason)

Global server-side logic for handling disconncted sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check
`reason` | String | Reason for disconnection

Source:
  - app/channel/channelManager.js, line 210

#### (async) handleRawRefresh(mediaObj) → {queuedMedia}

Refreshes expired raw links before media plays

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 978

##### Returns:

passes through Media object with updated link upon success

Type
  queuedMedia

#### kickConnections(user, reason)

Kicks a user from all channels by username

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to kick from the server
`reason` | String | Reason for kick

Source:
  - app/channel/channelManager.js, line 289

#### (async) livestreamOverwriteSchedule(wasPlaying, chanDB)

Overwrites livestream over scheduled media content after it has ended

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1239

#### (async) livestreamPushbackSchedule(wasPlaying, chanDB)

Pushes back any missed content scheduled during Livestream after Livestream has ended.

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1328

#### (async) markLinks(commandObj)

Iterates through links in message and marks them by link type for later use by client-side post-processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 126

#### (async) moveMedia(socket, data)

Processes request to move queued media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 238

#### (async) preSwitch(mediaObj)

Called 10 seconds before media begins to play

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 969

#### (async) prepMessage(commandObj)

Re-creates message string from processed Command Array

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 142

#### (async) prepQueue(chanDB)

Prepares channel queue for network transmission

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1582

##### Returns:

de-hydrated scehdule information

#### (async) preprocess(socket, data)

Ingests a command/chat request from Chat Handler and pre-processes and processes it accordingly

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/commandPreprocessor.js, line 47

#### (async) processServerCommand(commandObj)

Uses the server's Command Processor object to process the chat/command request.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 105

#### (async) queueChannelPlaylist(socket, data, chanDB)

Queues an entire channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 533

#### (async) queueFromChannelPlaylist(socket, data, chanDB)

Queues media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 646

#### queueFromChannelPlaylistValidator(socket, data) → {Number}

Validates client requests to queue media from a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 151

##### Returns:

returns validated start time on success

Type
  Number

#### (async) queueFromUserPlaylist(socket, data, userDB, chanDB)

Queues media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 697

#### (async) queueRandomFromChannelPlaylist(socket, data, chanDB)

Queues random media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 753

#### (async) queueRandomFromUserPlaylist(socket, data, userDB, chanDB)

Queues random media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 801

#### (async) queueURL(socket, data)

Accepts new URL's to queue from the client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the URL from
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 96

#### (async) queueUserPlaylist(socket, data, userDB, chanDB)

Queues an entire user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 587

#### (async) refreshCommands()

Reloads toke commands from DB into RAM-based toke command store

Source:
  - app/channel/tokebot.js, line 59

#### refreshNextTimer(volatile)

Calculates next item to play, and sets timer to play it at it's scheduled start

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`volatile` | Boolean | false | Disables DB Transactions if true

Source:
  - app/channel/media/queue.js, line 442

#### (async) rehydrateQueue(chanDB)

Rehydrates media schedule from DB

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1640

#### relayChannelAnnouncement(msg, links)

Broadcasts announcement to a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 305

#### relayChat(user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given channel

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`chan` | String |  | Channel to broadcast message within
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 179

#### relayChatObject(chan, chat)

Relays an existing chat object to a channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`chan` | String | Channel to broadcast message within
`chat` | chat | Chat Object representing the message to broadcast to the given channel

Source:
  - app/channel/chatHandler.js, line 188

#### relayGlobalChat(user, flair, highLevel, msg, type, links)

Creates a new chatObject and relays the resulting message to the entire server

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 237

#### relayGlobalChatObject(chat)

Relays an existing chat object to the entire server

##### Parameters:

Name | Type | Description
--- | --- | ---
`chat` | chat | Chat Object representing the message to broadcast throughout the server

Source:
  - app/channel/chatHandler.js, line 245

#### relayGlobalTokeWhisper(msg, links)

Broadcasts toke whisper to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 286

#### relayPrivateChat(socket, user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending a message to (sounds menacing, huh?)
`user` | String | Originating user
`flair` | String | Flair ID to mark chat with
`highLevel` | Number | High Level to mark chat with
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`chan` | String | Channel to broadcast message within
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 215

#### relayPrivateChatObject(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 224

#### relayServerAnnouncement(msg, links)

Broadcasts announcement to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 296

#### relayTokeCallout(msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 268

#### relayTokeWhisper(socket, msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending the whisper to
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 277

#### relayUserChat(socket, msg, type, links)

Relays a chat message from a user to the rest of the channel based on socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 257

#### (async) removeMedia(uuid, socket, chanDB, noScheduling) → {Media}

Removes a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`uuid` | String |  | UUID of item to reschedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`noScheduling` | Boolean | false | Disables schedule timer refresh if true

Source:
  - app/channel/media/queue.js, line 649

##### Returns:

Deleted Media Item

Type
  Media

#### (async) removeRange(start, end, socket, noUnfinished)

Removes range of media items from the queue

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (millis)
`end` | Number |  | End date by JS Epoch (millis)
`socket` | Socket |  | Requesting Socket
`noUnfinished` | Boolean | false | Set to true to include items that may be currently playing

Source:
  - app/channel/media/queue.js, line 492

#### (async) renameChannelPlaylist(socket, data, chanDB)

Renames a channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 855

#### renameChannelPlaylistValidator(socket, data) → {String}

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 170

##### Returns:

returns escaped/trimmed name upon success

Type
  String

#### (async) renameUserPlaylist(socket, data, userDB)

Renames a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 912

#### (async) rescheduleMedia(uuid, start, socket, chanDB)

Reschedules a media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule
`start` | Number | New start time by JS Epoch (Millis)
`socket` | Socket | Requesting Socket
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/queue.js, line 544

#### resetToke()

Resets toke cooldowns early upon authorized request

Source:
  - app/channel/tokebot.js, line 222

#### sanatizeCommand(commandObj) → {Boolean}

Sanatizes and Validates a single user chat message/command

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 82

##### Returns:

false if Command/Message is too long to send

Type
  Boolean

#### (async) scheduleMedia(media, socket, chanDB, force, volatile, startVolatile, saveLate, noSave)

Schedules a Media Item This is a fun method and I think it deserves it's own little explination... Since we're working with a time based schedule, using start epochs as keys for our iterable seemed the best option I don't want to store everything in a sparse array because that *feels* icky, and would probably be a pain in the ass. Maps seem like a good choice, if it wheren't for the issue of keeping them ordered... That's where this comes in. You see if we temporarily store it in a sparse array and convert into a map, we can quickly and easily create a properly sorted schedule map that, out side of adding items, behaves normally. Also a note on preformance: While .forEach ONLY runs through populated items in sparse arrays, many JS implementations run through them in the background, simply skipping them before executing the provided function. Looping through object.keys(arr), however, avoids this entirely, since it ONLY loops through defiened items within the array. No skipped empties for your runtime to worry about. Even more preformance benefits can be had by using a real for loop on the arrays keys, skipping the overhead of forEach entirely. This might seem gross but it completely avoids the computational workload of a sorting algo, especially when you consider that, no matter what, re-ordering the schedule map would've required us to iterate through and rebuild the map anyways... Also it looks like due to implementation limitations, epochs stored as MS are too large for array elements, so we store them there as seconds. This also means that our current implementation will break exactly on unix epoch 4294967295 (Feb 7, 2106 6:28:15 AM UTC) Hopefully javascript arrays will allow for larger lengths by then. If not blame the W3C :P If for some reason they haven't and we're not dead, we could probably implement an object that wraps a 2d array and set/gets it using modulo/devision/multiplication Further Reading: https://stackoverflow.com/questions/59480871/foreach-vs-object-keys-foreach-performance-on-sparse-arrays https://community.appsmith.com/content/blog/dark-side-foreach-why-you-should-think-twice-using-it

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`media` | Media |  | Media item to schedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`force` | Boolean | false | Ignore certain conditions that would prevent scehduling and play the bitch anyways, used for internal function calls
`volatile` | Boolean | false | Prevent DB Writes, used for internal function calls
`startVolatile` | Boolean | false | Runs refreshNextTimer calls without DB writes, used for internal function calls
`saveLate` | Boolean | false | Saves items even if they're about to, or have already started. Used for internal function calls
`noSave` | Boolean | false | Allows function to edit Channel Document, but not save. Used for internal function calls in which the channel document is passed through, but will be saved immediatly after the scheduleMedia() call.

Source:
  - app/channel/media/queue.js, line 819

#### (async) sendChanEmotes(chanDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 220

#### sendChat(commandObj)

Relays chat to channel via parent Chat Handler object

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 153

#### (async) sendClientMetadata(userDB, chanDB)

Sends glut of required initial metadata to the client upon a new connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 141

#### sendMedia(socket)

Send media update to a specific socket or broadcast it to the entire channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1550

#### (async) sendPersonalEmotes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 238

#### (async) sendSiteEmotes()

Send copy of site emotes to the user

Source:
  - app/channel/connectedUser.js, line 208

#### (async) sendUsedTokes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 256

#### (async) setFlair(socket, data)

Handles incoming client request to change flair

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 71

#### (async) setHighLevel(socket, data)

Handles incoming client request to change high level

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 95

#### socketCrawl(cb)

Iterates through all known connections for a given user, running them through a supplied callback function

##### Parameters:

Name | Type | Description
--- | --- | ---
`cb` | function | Callback to call against found sockets for a given user

Source:
  - app/channel/connectedUser.js, line 92

#### splitCommand(commandObj)

Splits raw chat/command data into seperate arrays, one by word-borders and words surrounded by word-borders These arrays are used to handle further command/chat processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 95

#### (async) start(mediaObj, timestamp, volatile)

Kicks off a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`mediaObj` | queuedMedia |  | Media object that's about to play
`timestamp` | Number |  | Media start timestamp in seconds
`volatile` | Boolean | false | Disables DB Transactions

Source:
  - app/channel/media/queue.js, line 998

#### stop(socket)

Stops currently playing media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1414

##### Returns:

returns false if there is nothing to stop

#### (async) stopMedia(socket)

Processes requests to stop currently playing media from client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we received the request from

Source:
  - app/channel/media/queue.js, line 159

#### (async) stopScheduleTimers(noArchive)

Clears and scheduling timers

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`noArchive` | Boolean | true | Disables Archiving

Source:
  - app/channel/media/queue.js, line 383

#### sync()

Sends a syncronization ping out to client Sockets and increments the tracked timestamp by the Synchronization Delta Called auto-magically by the Synchronization Timer

Source:
  - app/channel/media/queue.js, line 1066

#### (async) toggleLock(socket)

Handle client request to (un)lock queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket

Source:
  - app/channel/media/queue.js, line 270

#### tokeProcessor(commandObj) → {Boolean}

Processes toke commands from Command Pre-Processor

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request, passed down from the Command Pre-Processor

Source:
  - app/channel/tokebot.js, line 69

##### Returns:

True if the toke is an invalid toke command (tells Command Pre-Processor to send command as chat)

Type
  Boolean

#### updateFlair(flair)

Set flair for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`flair` | String | Flair string to update user's flair to

Source:
  - app/channel/connectedUser.js, line 273

#### updateHighLevel(highLevel)

Set high level for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`highLevel` | Number | Number to update user's high-level to

Source:
  - app/channel/connectedUser.js, line 284

#### (async) validateSocket(socket) → {Boolean}

Global server-side validation logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 110

##### Returns:

true on success

Type
  Boolean

## exports(server, channel)

Class containing playlist management logic for a single channel

## Constructor

#### new exports(server, channel)

Instantiates a new object to handle playlist management for a single channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`server` | channelManager | Parent server object
`channel` | activeChannel | Parent Channel object for desired channel queue

Source:
  - app/channel/media/playlistHandler.js, line 30

### Methods

#### (async) addPersonalEmote(socket, data)

Handles incoming client request to add a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 123

#### (async) addToChannelPlaylist(socket, data, chanDB)

Adds media to channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 434

#### (async) addToPlaylistValidator(socket, URL) → {Array}

Validates client requests to add media to a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`URL` | String | URL String handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 116

##### Returns:

List of media objects which where added

Type
  Array

#### (async) addToUserPlaylist(socket, data, userDB)

Adds media to user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 485

#### (async) asyncFinisher()

This method seems to be a vestage from a bygone era. We should remove it after documenting shit. I would now, but I don't want to break shit in a comment-only commit.

Source:
  - app/channel/tokebot.js, line 194

#### (async) authSocket(socket) → {Mongoose.Document}

Global server-side authorization logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 152

##### Returns:

- Authorized User Document upon success

Type
  Mongoose.Document

#### (async) broadcastChanEmotes(chanDB)

Broadcasts channel emote list to connected users

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/activeChannel.js, line 140

#### (async) broadcastQueue(chanDB)

Broadcasts channel queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1573

#### (async) broadcastSiteEmotes()

Broadcast global emote list

Source:
  - app/channel/channelManager.js, line 297

#### broadcastUserList()

Broadcasts user list to all users

Source:
  - app/channel/activeChannel.js, line 117

#### (async) changeDefaultTitlesChannelPlaylist(socket, data, chanDB)

Changes default titles for a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 968

#### (async) changeDefaultTitlesUserPlaylist(socket, data, userDB)

Changes default titles for a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1008

#### changeDefaultTitlesValidator(data) → {Array}

Validates client requests to change default titles for a given playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 188

##### Returns:

Array of strings containing valid titles from the output

Type
  Array

#### clearChat(user, chan)

Clears chat for a given channel, targets specified user or entire channel if none found/specified.

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | User chats to clear
`chan` | String | Channel to broadcast message within

Source:
  - app/channel/chatHandler.js, line 320

#### cooldown()

Runs every second for 60 seconds after a toke

Source:
  - app/channel/tokebot.js, line 205

#### countdown()

Called each second during the toke. Handles decrementing the timer variable, and countdown end logic.

Source:
  - app/channel/tokebot.js, line 148

#### crawlConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 254

#### (async) createChannelPlaylist(socket, data, chanDB)

Creates a new channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 270

#### createPlaylistValidator(socket, data) → {Object}

Validates client requests to create a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 80

##### Returns:

returns validated titles

Type
  Object

#### (async) createUserPlaylist(socket, data, userDB)

Creates a new user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 319

#### defineListeners(socket)

Define Global Server-Side socket event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 200

#### defineListeners(socket)

Defines global server-side chat relay event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/chatHandler.js, line 49

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/playlistHandler.js, line 47

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/queue.js, line 79

#### (async) deleteChannelPlaylist(socket, data, userDB)

Deletes a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 367

#### (async) deleteChannelPlaylistMedia(socket, data, chanDB)

Deletes media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1048

#### (async) deleteMedia(socket, data)

Processes client requests to delete queued media

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 178

#### (async) deletePersonalEmote(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 158

#### deletePlaylistMediaValidator(socket, data)

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 210

#### (async) deleteRange(socket, data)

Processes request to delete a range of media items from the queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 205

#### (async) deleteUserPlaylist(socket, data, chanDB)

Deletes a Channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 401

#### (async) deleteUserPlaylistMedia(socket, data, userDB)

Deletes media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1097

#### disconnect(reason, type)

Disconnects all sockets for a given user

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`reason` | String |  | Reason for being disconnected
`type` | String | Disconnected | Disconnection Type

Source:
  - app/channel/connectedUser.js, line 129

#### emit(eventName, data)

Emits an event to all known sockets for a given user My brain keeps going back to using dynamic per-user namespaces for this but everytime i look into it I come to the conclusion that it's a bad idea, then I toy with making chans namespaces and using per-user channels for this, but what of gold or mod-only features? or games? No matter what it'd probably end up hacky, as namespaces where meant for splitting app logic not user comms (like rooms). at the end of the day there has to be some penance for decent multi-session handling on-top of a library that doesn't do it. Having to crawl through these sockets is that. Because the other ways seem more gross somehow.

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventName` | String | Event name to emit to client sockets
`data` | Object | Data to emit to client sockets

Source:
  - app/channel/connectedUser.js, line 115

#### (async) end(quiet, noArchive, volatile, chanDB)

End currently playing media

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`quiet` | Boolean | false | Enable to prevent ending the media client-side
`noArchive` | Boolean | false | Enable to prevent ended media from being written to channel archive. Deletes media if Volatile is false
`volatile` | Boolean | false | Enable to prevent DB Transactions
`chanDB` | Mongoose.Document |  | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1099

#### (async) endLivestream(wasPlaying, chanDB)

Ends running Livestream

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1183

#### fromMedia(media, startTime, startTimeStamp) → {queuedMedia}

Creates a queuedMedia object from a media object

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | media | Media object to queue
`startTime` | Number | Start time formatted as a JS Epoch
`startTimeStamp` | Number | Start time stamp in seconds

Source:
  - app/channel/media/queuedMedia.js, line 62

##### Returns:

queuedMedia object created from given media object

Type
  queuedMedia

#### fromMediaArray(mediaList, start)

Converts array of media objects into array of queuedMedia objects

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaList` | Array | Array of media objects to queue
`start` | Number | Start time formatted as JS Epoch

Source:
  - app/channel/media/queuedMedia.js, line 82

##### Returns:

Array of converted queued media objects

#### genUUID()

Generates new unique identifier for queued media

Source:
  - app/channel/media/queuedMedia.js, line 103

#### (async) getActiveChan(socket) → {Object}

Gets active channel from a given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 174

##### Returns:

Object containing users active channel name and channel document object

Type
  Object

#### (async) getChannelPlaylists(socket, chanDB)

Sends channel playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 228

#### getConnectedChannels(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 230

##### Returns:

returns related user info

#### getConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 272

#### getEndTime(fullTime)

return the end time of a given queuedMedia object

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`fullTime` | boolean | false | Overrides early ends

Source:
  - app/channel/media/queuedMedia.js, line 112

##### Returns:

end time of given queuedMedia object

#### getItemAtEpoch(epoch) → {queuedMedia}

Gets a media item by epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis)

Source:
  - app/channel/media/queue.js, line 1471

##### Returns:

found media item

Type
  queuedMedia

#### getItemByUUID(uuid) → {queuedMedia}

Get Scheduled Item by UUID

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule

Source:
  - app/channel/media/queue.js, line 1535

##### Returns:

found item

Type
  queuedMedia

#### getItemsBetweenEpochs(start, end, noUnfinished) → {queuedMedia}

Returns scheduled media between two given datetimes

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (Millis)
`end` | Number |  | End date by JS Epoch (Millis)
`noUnfinished` | Boolean | false | Enable to include currently playing media

Source:
  - app/channel/media/queue.js, line 1446

##### Returns:

Found Media Objects

Type
  queuedMedia

#### getLastItem(epoch)

Gets last item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1490

##### Returns:

Last played item

#### getNextItem(epoch) → {queuedMedia}

Gets next item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1520

##### Returns:

Next item on the schedule

Type
  queuedMedia

#### getSocketInfo(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 220

##### Returns:

returns related user info

#### getStart(start)

Validates start times, and replaces bad ones with 5ms in the future

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | Start time to validate by JS Epoch (millis)

Source:
  - app/channel/media/queue.js, line 407

##### Returns:

Start time as JS Epoch (millis)

#### (async) getUserPlaylists(socket, userDB)

Sends user playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`userDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 248

#### (async) goLive(socket, data)

Handle client request to start an HLS live stream

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 289

#### handleChat(socket, data)

Handles incoming chat messages from client connections

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 62

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections to the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 53

#### (async) handleConnection(socket)

Handles global server-side initialization for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 57

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections from a specific user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/connectedUser.js, line 63

#### handleDisconnect(socket)

Handles server-side initialization for disconnecting from the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 92

#### handleDisconnect(socket, reason)

Global server-side logic for handling disconncted sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check
`reason` | String | Reason for disconnection

Source:
  - app/channel/channelManager.js, line 210

#### (async) handleRawRefresh(mediaObj) → {queuedMedia}

Refreshes expired raw links before media plays

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 978

##### Returns:

passes through Media object with updated link upon success

Type
  queuedMedia

#### kickConnections(user, reason)

Kicks a user from all channels by username

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to kick from the server
`reason` | String | Reason for kick

Source:
  - app/channel/channelManager.js, line 289

#### (async) livestreamOverwriteSchedule(wasPlaying, chanDB)

Overwrites livestream over scheduled media content after it has ended

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1239

#### (async) livestreamPushbackSchedule(wasPlaying, chanDB)

Pushes back any missed content scheduled during Livestream after Livestream has ended.

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1328

#### (async) markLinks(commandObj)

Iterates through links in message and marks them by link type for later use by client-side post-processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 126

#### (async) moveMedia(socket, data)

Processes request to move queued media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 238

#### (async) preSwitch(mediaObj)

Called 10 seconds before media begins to play

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 969

#### (async) prepMessage(commandObj)

Re-creates message string from processed Command Array

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 142

#### (async) prepQueue(chanDB)

Prepares channel queue for network transmission

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1582

##### Returns:

de-hydrated scehdule information

#### (async) preprocess(socket, data)

Ingests a command/chat request from Chat Handler and pre-processes and processes it accordingly

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/commandPreprocessor.js, line 47

#### (async) processServerCommand(commandObj)

Uses the server's Command Processor object to process the chat/command request.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 105

#### (async) queueChannelPlaylist(socket, data, chanDB)

Queues an entire channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 533

#### (async) queueFromChannelPlaylist(socket, data, chanDB)

Queues media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 646

#### queueFromChannelPlaylistValidator(socket, data) → {Number}

Validates client requests to queue media from a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 151

##### Returns:

returns validated start time on success

Type
  Number

#### (async) queueFromUserPlaylist(socket, data, userDB, chanDB)

Queues media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 697

#### (async) queueRandomFromChannelPlaylist(socket, data, chanDB)

Queues random media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 753

#### (async) queueRandomFromUserPlaylist(socket, data, userDB, chanDB)

Queues random media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 801

#### (async) queueURL(socket, data)

Accepts new URL's to queue from the client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the URL from
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 96

#### (async) queueUserPlaylist(socket, data, userDB, chanDB)

Queues an entire user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 587

#### (async) refreshCommands()

Reloads toke commands from DB into RAM-based toke command store

Source:
  - app/channel/tokebot.js, line 59

#### refreshNextTimer(volatile)

Calculates next item to play, and sets timer to play it at it's scheduled start

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`volatile` | Boolean | false | Disables DB Transactions if true

Source:
  - app/channel/media/queue.js, line 442

#### (async) rehydrateQueue(chanDB)

Rehydrates media schedule from DB

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1640

#### relayChannelAnnouncement(msg, links)

Broadcasts announcement to a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 305

#### relayChat(user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given channel

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`chan` | String |  | Channel to broadcast message within
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 179

#### relayChatObject(chan, chat)

Relays an existing chat object to a channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`chan` | String | Channel to broadcast message within
`chat` | chat | Chat Object representing the message to broadcast to the given channel

Source:
  - app/channel/chatHandler.js, line 188

#### relayGlobalChat(user, flair, highLevel, msg, type, links)

Creates a new chatObject and relays the resulting message to the entire server

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 237

#### relayGlobalChatObject(chat)

Relays an existing chat object to the entire server

##### Parameters:

Name | Type | Description
--- | --- | ---
`chat` | chat | Chat Object representing the message to broadcast throughout the server

Source:
  - app/channel/chatHandler.js, line 245

#### relayGlobalTokeWhisper(msg, links)

Broadcasts toke whisper to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 286

#### relayPrivateChat(socket, user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending a message to (sounds menacing, huh?)
`user` | String | Originating user
`flair` | String | Flair ID to mark chat with
`highLevel` | Number | High Level to mark chat with
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`chan` | String | Channel to broadcast message within
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 215

#### relayPrivateChatObject(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 224

#### relayServerAnnouncement(msg, links)

Broadcasts announcement to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 296

#### relayTokeCallout(msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 268

#### relayTokeWhisper(socket, msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending the whisper to
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 277

#### relayUserChat(socket, msg, type, links)

Relays a chat message from a user to the rest of the channel based on socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 257

#### (async) removeMedia(uuid, socket, chanDB, noScheduling) → {Media}

Removes a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`uuid` | String |  | UUID of item to reschedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`noScheduling` | Boolean | false | Disables schedule timer refresh if true

Source:
  - app/channel/media/queue.js, line 649

##### Returns:

Deleted Media Item

Type
  Media

#### (async) removeRange(start, end, socket, noUnfinished)

Removes range of media items from the queue

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (millis)
`end` | Number |  | End date by JS Epoch (millis)
`socket` | Socket |  | Requesting Socket
`noUnfinished` | Boolean | false | Set to true to include items that may be currently playing

Source:
  - app/channel/media/queue.js, line 492

#### (async) renameChannelPlaylist(socket, data, chanDB)

Renames a channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 855

#### renameChannelPlaylistValidator(socket, data) → {String}

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 170

##### Returns:

returns escaped/trimmed name upon success

Type
  String

#### (async) renameUserPlaylist(socket, data, userDB)

Renames a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 912

#### (async) rescheduleMedia(uuid, start, socket, chanDB)

Reschedules a media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule
`start` | Number | New start time by JS Epoch (Millis)
`socket` | Socket | Requesting Socket
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/queue.js, line 544

#### resetToke()

Resets toke cooldowns early upon authorized request

Source:
  - app/channel/tokebot.js, line 222

#### sanatizeCommand(commandObj) → {Boolean}

Sanatizes and Validates a single user chat message/command

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 82

##### Returns:

false if Command/Message is too long to send

Type
  Boolean

#### (async) scheduleMedia(media, socket, chanDB, force, volatile, startVolatile, saveLate, noSave)

Schedules a Media Item This is a fun method and I think it deserves it's own little explination... Since we're working with a time based schedule, using start epochs as keys for our iterable seemed the best option I don't want to store everything in a sparse array because that *feels* icky, and would probably be a pain in the ass. Maps seem like a good choice, if it wheren't for the issue of keeping them ordered... That's where this comes in. You see if we temporarily store it in a sparse array and convert into a map, we can quickly and easily create a properly sorted schedule map that, out side of adding items, behaves normally. Also a note on preformance: While .forEach ONLY runs through populated items in sparse arrays, many JS implementations run through them in the background, simply skipping them before executing the provided function. Looping through object.keys(arr), however, avoids this entirely, since it ONLY loops through defiened items within the array. No skipped empties for your runtime to worry about. Even more preformance benefits can be had by using a real for loop on the arrays keys, skipping the overhead of forEach entirely. This might seem gross but it completely avoids the computational workload of a sorting algo, especially when you consider that, no matter what, re-ordering the schedule map would've required us to iterate through and rebuild the map anyways... Also it looks like due to implementation limitations, epochs stored as MS are too large for array elements, so we store them there as seconds. This also means that our current implementation will break exactly on unix epoch 4294967295 (Feb 7, 2106 6:28:15 AM UTC) Hopefully javascript arrays will allow for larger lengths by then. If not blame the W3C :P If for some reason they haven't and we're not dead, we could probably implement an object that wraps a 2d array and set/gets it using modulo/devision/multiplication Further Reading: https://stackoverflow.com/questions/59480871/foreach-vs-object-keys-foreach-performance-on-sparse-arrays https://community.appsmith.com/content/blog/dark-side-foreach-why-you-should-think-twice-using-it

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`media` | Media |  | Media item to schedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`force` | Boolean | false | Ignore certain conditions that would prevent scehduling and play the bitch anyways, used for internal function calls
`volatile` | Boolean | false | Prevent DB Writes, used for internal function calls
`startVolatile` | Boolean | false | Runs refreshNextTimer calls without DB writes, used for internal function calls
`saveLate` | Boolean | false | Saves items even if they're about to, or have already started. Used for internal function calls
`noSave` | Boolean | false | Allows function to edit Channel Document, but not save. Used for internal function calls in which the channel document is passed through, but will be saved immediatly after the scheduleMedia() call.

Source:
  - app/channel/media/queue.js, line 819

#### (async) sendChanEmotes(chanDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 220

#### sendChat(commandObj)

Relays chat to channel via parent Chat Handler object

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 153

#### (async) sendClientMetadata(userDB, chanDB)

Sends glut of required initial metadata to the client upon a new connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 141

#### sendMedia(socket)

Send media update to a specific socket or broadcast it to the entire channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1550

#### (async) sendPersonalEmotes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 238

#### (async) sendSiteEmotes()

Send copy of site emotes to the user

Source:
  - app/channel/connectedUser.js, line 208

#### (async) sendUsedTokes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 256

#### (async) setFlair(socket, data)

Handles incoming client request to change flair

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 71

#### (async) setHighLevel(socket, data)

Handles incoming client request to change high level

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 95

#### socketCrawl(cb)

Iterates through all known connections for a given user, running them through a supplied callback function

##### Parameters:

Name | Type | Description
--- | --- | ---
`cb` | function | Callback to call against found sockets for a given user

Source:
  - app/channel/connectedUser.js, line 92

#### splitCommand(commandObj)

Splits raw chat/command data into seperate arrays, one by word-borders and words surrounded by word-borders These arrays are used to handle further command/chat processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 95

#### (async) start(mediaObj, timestamp, volatile)

Kicks off a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`mediaObj` | queuedMedia |  | Media object that's about to play
`timestamp` | Number |  | Media start timestamp in seconds
`volatile` | Boolean | false | Disables DB Transactions

Source:
  - app/channel/media/queue.js, line 998

#### stop(socket)

Stops currently playing media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1414

##### Returns:

returns false if there is nothing to stop

#### (async) stopMedia(socket)

Processes requests to stop currently playing media from client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we received the request from

Source:
  - app/channel/media/queue.js, line 159

#### (async) stopScheduleTimers(noArchive)

Clears and scheduling timers

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`noArchive` | Boolean | true | Disables Archiving

Source:
  - app/channel/media/queue.js, line 383

#### sync()

Sends a syncronization ping out to client Sockets and increments the tracked timestamp by the Synchronization Delta Called auto-magically by the Synchronization Timer

Source:
  - app/channel/media/queue.js, line 1066

#### (async) toggleLock(socket)

Handle client request to (un)lock queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket

Source:
  - app/channel/media/queue.js, line 270

#### tokeProcessor(commandObj) → {Boolean}

Processes toke commands from Command Pre-Processor

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request, passed down from the Command Pre-Processor

Source:
  - app/channel/tokebot.js, line 69

##### Returns:

True if the toke is an invalid toke command (tells Command Pre-Processor to send command as chat)

Type
  Boolean

#### updateFlair(flair)

Set flair for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`flair` | String | Flair string to update user's flair to

Source:
  - app/channel/connectedUser.js, line 273

#### updateHighLevel(highLevel)

Set high level for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`highLevel` | Number | Number to update user's high-level to

Source:
  - app/channel/connectedUser.js, line 284

#### (async) validateSocket(socket) → {Boolean}

Global server-side validation logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 110

##### Returns:

true on success

Type
  Boolean

## exports(server, chanDB, channel)

Object represneting a single channel's media queue

## Constructor

#### new exports(server, chanDB, channel)

Instantiates a new media queue for a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`server` | channelManager | Parent server object
`chanDB` | Document | Related Channel Document from DB
`channel` | activeChannel | Parent Channel object for desired channel queue

Source:
  - app/channel/media/queue.js, line 29

### Methods

#### (async) addPersonalEmote(socket, data)

Handles incoming client request to add a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 123

#### (async) addToChannelPlaylist(socket, data, chanDB)

Adds media to channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 434

#### (async) addToPlaylistValidator(socket, URL) → {Array}

Validates client requests to add media to a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`URL` | String | URL String handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 116

##### Returns:

List of media objects which where added

Type
  Array

#### (async) addToUserPlaylist(socket, data, userDB)

Adds media to user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 485

#### (async) asyncFinisher()

This method seems to be a vestage from a bygone era. We should remove it after documenting shit. I would now, but I don't want to break shit in a comment-only commit.

Source:
  - app/channel/tokebot.js, line 194

#### (async) authSocket(socket) → {Mongoose.Document}

Global server-side authorization logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 152

##### Returns:

- Authorized User Document upon success

Type
  Mongoose.Document

#### (async) broadcastChanEmotes(chanDB)

Broadcasts channel emote list to connected users

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/activeChannel.js, line 140

#### (async) broadcastQueue(chanDB)

Broadcasts channel queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1573

#### (async) broadcastSiteEmotes()

Broadcast global emote list

Source:
  - app/channel/channelManager.js, line 297

#### broadcastUserList()

Broadcasts user list to all users

Source:
  - app/channel/activeChannel.js, line 117

#### (async) changeDefaultTitlesChannelPlaylist(socket, data, chanDB)

Changes default titles for a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 968

#### (async) changeDefaultTitlesUserPlaylist(socket, data, userDB)

Changes default titles for a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1008

#### changeDefaultTitlesValidator(data) → {Array}

Validates client requests to change default titles for a given playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 188

##### Returns:

Array of strings containing valid titles from the output

Type
  Array

#### clearChat(user, chan)

Clears chat for a given channel, targets specified user or entire channel if none found/specified.

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | User chats to clear
`chan` | String | Channel to broadcast message within

Source:
  - app/channel/chatHandler.js, line 320

#### cooldown()

Runs every second for 60 seconds after a toke

Source:
  - app/channel/tokebot.js, line 205

#### countdown()

Called each second during the toke. Handles decrementing the timer variable, and countdown end logic.

Source:
  - app/channel/tokebot.js, line 148

#### crawlConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 254

#### (async) createChannelPlaylist(socket, data, chanDB)

Creates a new channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 270

#### createPlaylistValidator(socket, data) → {Object}

Validates client requests to create a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 80

##### Returns:

returns validated titles

Type
  Object

#### (async) createUserPlaylist(socket, data, userDB)

Creates a new user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 319

#### defineListeners(socket)

Define Global Server-Side socket event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 200

#### defineListeners(socket)

Defines global server-side chat relay event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/chatHandler.js, line 49

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/playlistHandler.js, line 47

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/queue.js, line 79

#### (async) deleteChannelPlaylist(socket, data, userDB)

Deletes a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 367

#### (async) deleteChannelPlaylistMedia(socket, data, chanDB)

Deletes media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1048

#### (async) deleteMedia(socket, data)

Processes client requests to delete queued media

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 178

#### (async) deletePersonalEmote(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 158

#### deletePlaylistMediaValidator(socket, data)

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 210

#### (async) deleteRange(socket, data)

Processes request to delete a range of media items from the queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 205

#### (async) deleteUserPlaylist(socket, data, chanDB)

Deletes a Channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 401

#### (async) deleteUserPlaylistMedia(socket, data, userDB)

Deletes media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1097

#### disconnect(reason, type)

Disconnects all sockets for a given user

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`reason` | String |  | Reason for being disconnected
`type` | String | Disconnected | Disconnection Type

Source:
  - app/channel/connectedUser.js, line 129

#### emit(eventName, data)

Emits an event to all known sockets for a given user My brain keeps going back to using dynamic per-user namespaces for this but everytime i look into it I come to the conclusion that it's a bad idea, then I toy with making chans namespaces and using per-user channels for this, but what of gold or mod-only features? or games? No matter what it'd probably end up hacky, as namespaces where meant for splitting app logic not user comms (like rooms). at the end of the day there has to be some penance for decent multi-session handling on-top of a library that doesn't do it. Having to crawl through these sockets is that. Because the other ways seem more gross somehow.

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventName` | String | Event name to emit to client sockets
`data` | Object | Data to emit to client sockets

Source:
  - app/channel/connectedUser.js, line 115

#### (async) end(quiet, noArchive, volatile, chanDB)

End currently playing media

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`quiet` | Boolean | false | Enable to prevent ending the media client-side
`noArchive` | Boolean | false | Enable to prevent ended media from being written to channel archive. Deletes media if Volatile is false
`volatile` | Boolean | false | Enable to prevent DB Transactions
`chanDB` | Mongoose.Document |  | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1099

#### (async) endLivestream(wasPlaying, chanDB)

Ends running Livestream

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1183

#### fromMedia(media, startTime, startTimeStamp) → {queuedMedia}

Creates a queuedMedia object from a media object

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | media | Media object to queue
`startTime` | Number | Start time formatted as a JS Epoch
`startTimeStamp` | Number | Start time stamp in seconds

Source:
  - app/channel/media/queuedMedia.js, line 62

##### Returns:

queuedMedia object created from given media object

Type
  queuedMedia

#### fromMediaArray(mediaList, start)

Converts array of media objects into array of queuedMedia objects

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaList` | Array | Array of media objects to queue
`start` | Number | Start time formatted as JS Epoch

Source:
  - app/channel/media/queuedMedia.js, line 82

##### Returns:

Array of converted queued media objects

#### genUUID()

Generates new unique identifier for queued media

Source:
  - app/channel/media/queuedMedia.js, line 103

#### (async) getActiveChan(socket) → {Object}

Gets active channel from a given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 174

##### Returns:

Object containing users active channel name and channel document object

Type
  Object

#### (async) getChannelPlaylists(socket, chanDB)

Sends channel playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 228

#### getConnectedChannels(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 230

##### Returns:

returns related user info

#### getConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 272

#### getEndTime(fullTime)

return the end time of a given queuedMedia object

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`fullTime` | boolean | false | Overrides early ends

Source:
  - app/channel/media/queuedMedia.js, line 112

##### Returns:

end time of given queuedMedia object

#### getItemAtEpoch(epoch) → {queuedMedia}

Gets a media item by epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis)

Source:
  - app/channel/media/queue.js, line 1471

##### Returns:

found media item

Type
  queuedMedia

#### getItemByUUID(uuid) → {queuedMedia}

Get Scheduled Item by UUID

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule

Source:
  - app/channel/media/queue.js, line 1535

##### Returns:

found item

Type
  queuedMedia

#### getItemsBetweenEpochs(start, end, noUnfinished) → {queuedMedia}

Returns scheduled media between two given datetimes

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (Millis)
`end` | Number |  | End date by JS Epoch (Millis)
`noUnfinished` | Boolean | false | Enable to include currently playing media

Source:
  - app/channel/media/queue.js, line 1446

##### Returns:

Found Media Objects

Type
  queuedMedia

#### getLastItem(epoch)

Gets last item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1490

##### Returns:

Last played item

#### getNextItem(epoch) → {queuedMedia}

Gets next item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1520

##### Returns:

Next item on the schedule

Type
  queuedMedia

#### getSocketInfo(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 220

##### Returns:

returns related user info

#### getStart(start)

Validates start times, and replaces bad ones with 5ms in the future

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | Start time to validate by JS Epoch (millis)

Source:
  - app/channel/media/queue.js, line 407

##### Returns:

Start time as JS Epoch (millis)

#### (async) getUserPlaylists(socket, userDB)

Sends user playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`userDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 248

#### (async) goLive(socket, data)

Handle client request to start an HLS live stream

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 289

#### handleChat(socket, data)

Handles incoming chat messages from client connections

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 62

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections to the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 53

#### (async) handleConnection(socket)

Handles global server-side initialization for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 57

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections from a specific user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/connectedUser.js, line 63

#### handleDisconnect(socket)

Handles server-side initialization for disconnecting from the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 92

#### handleDisconnect(socket, reason)

Global server-side logic for handling disconncted sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check
`reason` | String | Reason for disconnection

Source:
  - app/channel/channelManager.js, line 210

#### (async) handleRawRefresh(mediaObj) → {queuedMedia}

Refreshes expired raw links before media plays

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 978

##### Returns:

passes through Media object with updated link upon success

Type
  queuedMedia

#### kickConnections(user, reason)

Kicks a user from all channels by username

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to kick from the server
`reason` | String | Reason for kick

Source:
  - app/channel/channelManager.js, line 289

#### (async) livestreamOverwriteSchedule(wasPlaying, chanDB)

Overwrites livestream over scheduled media content after it has ended

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1239

#### (async) livestreamPushbackSchedule(wasPlaying, chanDB)

Pushes back any missed content scheduled during Livestream after Livestream has ended.

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1328

#### (async) markLinks(commandObj)

Iterates through links in message and marks them by link type for later use by client-side post-processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 126

#### (async) moveMedia(socket, data)

Processes request to move queued media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 238

#### (async) preSwitch(mediaObj)

Called 10 seconds before media begins to play

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 969

#### (async) prepMessage(commandObj)

Re-creates message string from processed Command Array

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 142

#### (async) prepQueue(chanDB)

Prepares channel queue for network transmission

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1582

##### Returns:

de-hydrated scehdule information

#### (async) preprocess(socket, data)

Ingests a command/chat request from Chat Handler and pre-processes and processes it accordingly

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/commandPreprocessor.js, line 47

#### (async) processServerCommand(commandObj)

Uses the server's Command Processor object to process the chat/command request.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 105

#### (async) queueChannelPlaylist(socket, data, chanDB)

Queues an entire channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 533

#### (async) queueFromChannelPlaylist(socket, data, chanDB)

Queues media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 646

#### queueFromChannelPlaylistValidator(socket, data) → {Number}

Validates client requests to queue media from a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 151

##### Returns:

returns validated start time on success

Type
  Number

#### (async) queueFromUserPlaylist(socket, data, userDB, chanDB)

Queues media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 697

#### (async) queueRandomFromChannelPlaylist(socket, data, chanDB)

Queues random media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 753

#### (async) queueRandomFromUserPlaylist(socket, data, userDB, chanDB)

Queues random media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 801

#### (async) queueURL(socket, data)

Accepts new URL's to queue from the client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the URL from
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 96

#### (async) queueUserPlaylist(socket, data, userDB, chanDB)

Queues an entire user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 587

#### (async) refreshCommands()

Reloads toke commands from DB into RAM-based toke command store

Source:
  - app/channel/tokebot.js, line 59

#### refreshNextTimer(volatile)

Calculates next item to play, and sets timer to play it at it's scheduled start

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`volatile` | Boolean | false | Disables DB Transactions if true

Source:
  - app/channel/media/queue.js, line 442

#### (async) rehydrateQueue(chanDB)

Rehydrates media schedule from DB

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1640

#### relayChannelAnnouncement(msg, links)

Broadcasts announcement to a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 305

#### relayChat(user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given channel

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`chan` | String |  | Channel to broadcast message within
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 179

#### relayChatObject(chan, chat)

Relays an existing chat object to a channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`chan` | String | Channel to broadcast message within
`chat` | chat | Chat Object representing the message to broadcast to the given channel

Source:
  - app/channel/chatHandler.js, line 188

#### relayGlobalChat(user, flair, highLevel, msg, type, links)

Creates a new chatObject and relays the resulting message to the entire server

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 237

#### relayGlobalChatObject(chat)

Relays an existing chat object to the entire server

##### Parameters:

Name | Type | Description
--- | --- | ---
`chat` | chat | Chat Object representing the message to broadcast throughout the server

Source:
  - app/channel/chatHandler.js, line 245

#### relayGlobalTokeWhisper(msg, links)

Broadcasts toke whisper to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 286

#### relayPrivateChat(socket, user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending a message to (sounds menacing, huh?)
`user` | String | Originating user
`flair` | String | Flair ID to mark chat with
`highLevel` | Number | High Level to mark chat with
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`chan` | String | Channel to broadcast message within
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 215

#### relayPrivateChatObject(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 224

#### relayServerAnnouncement(msg, links)

Broadcasts announcement to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 296

#### relayTokeCallout(msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 268

#### relayTokeWhisper(socket, msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending the whisper to
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 277

#### relayUserChat(socket, msg, type, links)

Relays a chat message from a user to the rest of the channel based on socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 257

#### (async) removeMedia(uuid, socket, chanDB, noScheduling) → {Media}

Removes a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`uuid` | String |  | UUID of item to reschedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`noScheduling` | Boolean | false | Disables schedule timer refresh if true

Source:
  - app/channel/media/queue.js, line 649

##### Returns:

Deleted Media Item

Type
  Media

#### (async) removeRange(start, end, socket, noUnfinished)

Removes range of media items from the queue

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (millis)
`end` | Number |  | End date by JS Epoch (millis)
`socket` | Socket |  | Requesting Socket
`noUnfinished` | Boolean | false | Set to true to include items that may be currently playing

Source:
  - app/channel/media/queue.js, line 492

#### (async) renameChannelPlaylist(socket, data, chanDB)

Renames a channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 855

#### renameChannelPlaylistValidator(socket, data) → {String}

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 170

##### Returns:

returns escaped/trimmed name upon success

Type
  String

#### (async) renameUserPlaylist(socket, data, userDB)

Renames a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 912

#### (async) rescheduleMedia(uuid, start, socket, chanDB)

Reschedules a media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule
`start` | Number | New start time by JS Epoch (Millis)
`socket` | Socket | Requesting Socket
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/queue.js, line 544

#### resetToke()

Resets toke cooldowns early upon authorized request

Source:
  - app/channel/tokebot.js, line 222

#### sanatizeCommand(commandObj) → {Boolean}

Sanatizes and Validates a single user chat message/command

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 82

##### Returns:

false if Command/Message is too long to send

Type
  Boolean

#### (async) scheduleMedia(media, socket, chanDB, force, volatile, startVolatile, saveLate, noSave)

Schedules a Media Item This is a fun method and I think it deserves it's own little explination... Since we're working with a time based schedule, using start epochs as keys for our iterable seemed the best option I don't want to store everything in a sparse array because that *feels* icky, and would probably be a pain in the ass. Maps seem like a good choice, if it wheren't for the issue of keeping them ordered... That's where this comes in. You see if we temporarily store it in a sparse array and convert into a map, we can quickly and easily create a properly sorted schedule map that, out side of adding items, behaves normally. Also a note on preformance: While .forEach ONLY runs through populated items in sparse arrays, many JS implementations run through them in the background, simply skipping them before executing the provided function. Looping through object.keys(arr), however, avoids this entirely, since it ONLY loops through defiened items within the array. No skipped empties for your runtime to worry about. Even more preformance benefits can be had by using a real for loop on the arrays keys, skipping the overhead of forEach entirely. This might seem gross but it completely avoids the computational workload of a sorting algo, especially when you consider that, no matter what, re-ordering the schedule map would've required us to iterate through and rebuild the map anyways... Also it looks like due to implementation limitations, epochs stored as MS are too large for array elements, so we store them there as seconds. This also means that our current implementation will break exactly on unix epoch 4294967295 (Feb 7, 2106 6:28:15 AM UTC) Hopefully javascript arrays will allow for larger lengths by then. If not blame the W3C :P If for some reason they haven't and we're not dead, we could probably implement an object that wraps a 2d array and set/gets it using modulo/devision/multiplication Further Reading: https://stackoverflow.com/questions/59480871/foreach-vs-object-keys-foreach-performance-on-sparse-arrays https://community.appsmith.com/content/blog/dark-side-foreach-why-you-should-think-twice-using-it

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`media` | Media |  | Media item to schedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`force` | Boolean | false | Ignore certain conditions that would prevent scehduling and play the bitch anyways, used for internal function calls
`volatile` | Boolean | false | Prevent DB Writes, used for internal function calls
`startVolatile` | Boolean | false | Runs refreshNextTimer calls without DB writes, used for internal function calls
`saveLate` | Boolean | false | Saves items even if they're about to, or have already started. Used for internal function calls
`noSave` | Boolean | false | Allows function to edit Channel Document, but not save. Used for internal function calls in which the channel document is passed through, but will be saved immediatly after the scheduleMedia() call.

Source:
  - app/channel/media/queue.js, line 819

#### (async) sendChanEmotes(chanDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 220

#### sendChat(commandObj)

Relays chat to channel via parent Chat Handler object

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 153

#### (async) sendClientMetadata(userDB, chanDB)

Sends glut of required initial metadata to the client upon a new connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 141

#### sendMedia(socket)

Send media update to a specific socket or broadcast it to the entire channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1550

#### (async) sendPersonalEmotes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 238

#### (async) sendSiteEmotes()

Send copy of site emotes to the user

Source:
  - app/channel/connectedUser.js, line 208

#### (async) sendUsedTokes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 256

#### (async) setFlair(socket, data)

Handles incoming client request to change flair

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 71

#### (async) setHighLevel(socket, data)

Handles incoming client request to change high level

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 95

#### socketCrawl(cb)

Iterates through all known connections for a given user, running them through a supplied callback function

##### Parameters:

Name | Type | Description
--- | --- | ---
`cb` | function | Callback to call against found sockets for a given user

Source:
  - app/channel/connectedUser.js, line 92

#### splitCommand(commandObj)

Splits raw chat/command data into seperate arrays, one by word-borders and words surrounded by word-borders These arrays are used to handle further command/chat processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 95

#### (async) start(mediaObj, timestamp, volatile)

Kicks off a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`mediaObj` | queuedMedia |  | Media object that's about to play
`timestamp` | Number |  | Media start timestamp in seconds
`volatile` | Boolean | false | Disables DB Transactions

Source:
  - app/channel/media/queue.js, line 998

#### stop(socket)

Stops currently playing media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1414

##### Returns:

returns false if there is nothing to stop

#### (async) stopMedia(socket)

Processes requests to stop currently playing media from client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we received the request from

Source:
  - app/channel/media/queue.js, line 159

#### (async) stopScheduleTimers(noArchive)

Clears and scheduling timers

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`noArchive` | Boolean | true | Disables Archiving

Source:
  - app/channel/media/queue.js, line 383

#### sync()

Sends a syncronization ping out to client Sockets and increments the tracked timestamp by the Synchronization Delta Called auto-magically by the Synchronization Timer

Source:
  - app/channel/media/queue.js, line 1066

#### (async) toggleLock(socket)

Handle client request to (un)lock queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket

Source:
  - app/channel/media/queue.js, line 270

#### tokeProcessor(commandObj) → {Boolean}

Processes toke commands from Command Pre-Processor

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request, passed down from the Command Pre-Processor

Source:
  - app/channel/tokebot.js, line 69

##### Returns:

True if the toke is an invalid toke command (tells Command Pre-Processor to send command as chat)

Type
  Boolean

#### updateFlair(flair)

Set flair for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`flair` | String | Flair string to update user's flair to

Source:
  - app/channel/connectedUser.js, line 273

#### updateHighLevel(highLevel)

Set high level for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`highLevel` | Number | Number to update user's high-level to

Source:
  - app/channel/connectedUser.js, line 284

#### (async) validateSocket(socket) → {Boolean}

Global server-side validation logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 110

##### Returns:

true on success

Type
  Boolean

## exports(startTime, startTimeStamp, earlyEnd, uuid)

Class extending media which represents a queued piece of media

## Constructor

#### new exports(startTime, startTimeStamp, earlyEnd, uuid)

Creates a new queued media object

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`startTime` | Number |  | JS Epoch representing start time
`startTimeStamp` | Number | 0 | Media start time stamp in seconds (relative to duration)
`earlyEnd` | Number |  | Media end timestamp in seconds (relative to duration)
`uuid` | String |  | Media object's unique identifier

Source:
  - app/channel/media/queuedMedia.js, line 24

### Extends

- media

### Methods

#### (async) addPersonalEmote(socket, data)

Handles incoming client request to add a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 123

#### (async) addToChannelPlaylist(socket, data, chanDB)

Adds media to channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 434

#### (async) addToPlaylistValidator(socket, URL) → {Array}

Validates client requests to add media to a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`URL` | String | URL String handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 116

##### Returns:

List of media objects which where added

Type
  Array

#### (async) addToUserPlaylist(socket, data, userDB)

Adds media to user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 485

#### (async) asyncFinisher()

This method seems to be a vestage from a bygone era. We should remove it after documenting shit. I would now, but I don't want to break shit in a comment-only commit.

Source:
  - app/channel/tokebot.js, line 194

#### (async) authSocket(socket) → {Mongoose.Document}

Global server-side authorization logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 152

##### Returns:

- Authorized User Document upon success

Type
  Mongoose.Document

#### (async) broadcastChanEmotes(chanDB)

Broadcasts channel emote list to connected users

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/activeChannel.js, line 140

#### (async) broadcastQueue(chanDB)

Broadcasts channel queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1573

#### (async) broadcastSiteEmotes()

Broadcast global emote list

Source:
  - app/channel/channelManager.js, line 297

#### broadcastUserList()

Broadcasts user list to all users

Source:
  - app/channel/activeChannel.js, line 117

#### (async) changeDefaultTitlesChannelPlaylist(socket, data, chanDB)

Changes default titles for a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 968

#### (async) changeDefaultTitlesUserPlaylist(socket, data, userDB)

Changes default titles for a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1008

#### changeDefaultTitlesValidator(data) → {Array}

Validates client requests to change default titles for a given playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 188

##### Returns:

Array of strings containing valid titles from the output

Type
  Array

#### clearChat(user, chan)

Clears chat for a given channel, targets specified user or entire channel if none found/specified.

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | User chats to clear
`chan` | String | Channel to broadcast message within

Source:
  - app/channel/chatHandler.js, line 320

#### cooldown()

Runs every second for 60 seconds after a toke

Source:
  - app/channel/tokebot.js, line 205

#### countdown()

Called each second during the toke. Handles decrementing the timer variable, and countdown end logic.

Source:
  - app/channel/tokebot.js, line 148

#### crawlConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 254

#### (async) createChannelPlaylist(socket, data, chanDB)

Creates a new channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 270

#### createPlaylistValidator(socket, data) → {Object}

Validates client requests to create a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 80

##### Returns:

returns validated titles

Type
  Object

#### (async) createUserPlaylist(socket, data, userDB)

Creates a new user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 319

#### defineListeners(socket)

Define Global Server-Side socket event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 200

#### defineListeners(socket)

Defines global server-side chat relay event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/chatHandler.js, line 49

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/playlistHandler.js, line 47

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/queue.js, line 79

#### (async) deleteChannelPlaylist(socket, data, userDB)

Deletes a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 367

#### (async) deleteChannelPlaylistMedia(socket, data, chanDB)

Deletes media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1048

#### (async) deleteMedia(socket, data)

Processes client requests to delete queued media

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 178

#### (async) deletePersonalEmote(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 158

#### deletePlaylistMediaValidator(socket, data)

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 210

#### (async) deleteRange(socket, data)

Processes request to delete a range of media items from the queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 205

#### (async) deleteUserPlaylist(socket, data, chanDB)

Deletes a Channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 401

#### (async) deleteUserPlaylistMedia(socket, data, userDB)

Deletes media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1097

#### disconnect(reason, type)

Disconnects all sockets for a given user

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`reason` | String |  | Reason for being disconnected
`type` | String | Disconnected | Disconnection Type

Source:
  - app/channel/connectedUser.js, line 129

#### emit(eventName, data)

Emits an event to all known sockets for a given user My brain keeps going back to using dynamic per-user namespaces for this but everytime i look into it I come to the conclusion that it's a bad idea, then I toy with making chans namespaces and using per-user channels for this, but what of gold or mod-only features? or games? No matter what it'd probably end up hacky, as namespaces where meant for splitting app logic not user comms (like rooms). at the end of the day there has to be some penance for decent multi-session handling on-top of a library that doesn't do it. Having to crawl through these sockets is that. Because the other ways seem more gross somehow.

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventName` | String | Event name to emit to client sockets
`data` | Object | Data to emit to client sockets

Source:
  - app/channel/connectedUser.js, line 115

#### (async) end(quiet, noArchive, volatile, chanDB)

End currently playing media

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`quiet` | Boolean | false | Enable to prevent ending the media client-side
`noArchive` | Boolean | false | Enable to prevent ended media from being written to channel archive. Deletes media if Volatile is false
`volatile` | Boolean | false | Enable to prevent DB Transactions
`chanDB` | Mongoose.Document |  | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1099

#### (async) endLivestream(wasPlaying, chanDB)

Ends running Livestream

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1183

#### fromMedia(media, startTime, startTimeStamp) → {queuedMedia}

Creates a queuedMedia object from a media object

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | media | Media object to queue
`startTime` | Number | Start time formatted as a JS Epoch
`startTimeStamp` | Number | Start time stamp in seconds

Source:
  - app/channel/media/queuedMedia.js, line 62

##### Returns:

queuedMedia object created from given media object

Type
  queuedMedia

#### fromMediaArray(mediaList, start)

Converts array of media objects into array of queuedMedia objects

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaList` | Array | Array of media objects to queue
`start` | Number | Start time formatted as JS Epoch

Source:
  - app/channel/media/queuedMedia.js, line 82

##### Returns:

Array of converted queued media objects

#### genUUID()

Generates new unique identifier for queued media

Source:
  - app/channel/media/queuedMedia.js, line 103

#### (async) getActiveChan(socket) → {Object}

Gets active channel from a given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 174

##### Returns:

Object containing users active channel name and channel document object

Type
  Object

#### (async) getChannelPlaylists(socket, chanDB)

Sends channel playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 228

#### getConnectedChannels(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 230

##### Returns:

returns related user info

#### getConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 272

#### getEndTime(fullTime)

return the end time of a given queuedMedia object

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`fullTime` | boolean | false | Overrides early ends

Source:
  - app/channel/media/queuedMedia.js, line 112

##### Returns:

end time of given queuedMedia object

#### getItemAtEpoch(epoch) → {queuedMedia}

Gets a media item by epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis)

Source:
  - app/channel/media/queue.js, line 1471

##### Returns:

found media item

Type
  queuedMedia

#### getItemByUUID(uuid) → {queuedMedia}

Get Scheduled Item by UUID

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule

Source:
  - app/channel/media/queue.js, line 1535

##### Returns:

found item

Type
  queuedMedia

#### getItemsBetweenEpochs(start, end, noUnfinished) → {queuedMedia}

Returns scheduled media between two given datetimes

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (Millis)
`end` | Number |  | End date by JS Epoch (Millis)
`noUnfinished` | Boolean | false | Enable to include currently playing media

Source:
  - app/channel/media/queue.js, line 1446

##### Returns:

Found Media Objects

Type
  queuedMedia

#### getLastItem(epoch)

Gets last item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1490

##### Returns:

Last played item

#### getNextItem(epoch) → {queuedMedia}

Gets next item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1520

##### Returns:

Next item on the schedule

Type
  queuedMedia

#### getSocketInfo(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 220

##### Returns:

returns related user info

#### getStart(start)

Validates start times, and replaces bad ones with 5ms in the future

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | Start time to validate by JS Epoch (millis)

Source:
  - app/channel/media/queue.js, line 407

##### Returns:

Start time as JS Epoch (millis)

#### (async) getUserPlaylists(socket, userDB)

Sends user playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`userDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 248

#### (async) goLive(socket, data)

Handle client request to start an HLS live stream

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 289

#### handleChat(socket, data)

Handles incoming chat messages from client connections

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 62

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections to the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 53

#### (async) handleConnection(socket)

Handles global server-side initialization for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 57

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections from a specific user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/connectedUser.js, line 63

#### handleDisconnect(socket)

Handles server-side initialization for disconnecting from the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 92

#### handleDisconnect(socket, reason)

Global server-side logic for handling disconncted sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check
`reason` | String | Reason for disconnection

Source:
  - app/channel/channelManager.js, line 210

#### (async) handleRawRefresh(mediaObj) → {queuedMedia}

Refreshes expired raw links before media plays

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 978

##### Returns:

passes through Media object with updated link upon success

Type
  queuedMedia

#### kickConnections(user, reason)

Kicks a user from all channels by username

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to kick from the server
`reason` | String | Reason for kick

Source:
  - app/channel/channelManager.js, line 289

#### (async) livestreamOverwriteSchedule(wasPlaying, chanDB)

Overwrites livestream over scheduled media content after it has ended

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1239

#### (async) livestreamPushbackSchedule(wasPlaying, chanDB)

Pushes back any missed content scheduled during Livestream after Livestream has ended.

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1328

#### (async) markLinks(commandObj)

Iterates through links in message and marks them by link type for later use by client-side post-processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 126

#### (async) moveMedia(socket, data)

Processes request to move queued media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 238

#### (async) preSwitch(mediaObj)

Called 10 seconds before media begins to play

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 969

#### (async) prepMessage(commandObj)

Re-creates message string from processed Command Array

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 142

#### (async) prepQueue(chanDB)

Prepares channel queue for network transmission

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1582

##### Returns:

de-hydrated scehdule information

#### (async) preprocess(socket, data)

Ingests a command/chat request from Chat Handler and pre-processes and processes it accordingly

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/commandPreprocessor.js, line 47

#### (async) processServerCommand(commandObj)

Uses the server's Command Processor object to process the chat/command request.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 105

#### (async) queueChannelPlaylist(socket, data, chanDB)

Queues an entire channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 533

#### (async) queueFromChannelPlaylist(socket, data, chanDB)

Queues media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 646

#### queueFromChannelPlaylistValidator(socket, data) → {Number}

Validates client requests to queue media from a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 151

##### Returns:

returns validated start time on success

Type
  Number

#### (async) queueFromUserPlaylist(socket, data, userDB, chanDB)

Queues media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 697

#### (async) queueRandomFromChannelPlaylist(socket, data, chanDB)

Queues random media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 753

#### (async) queueRandomFromUserPlaylist(socket, data, userDB, chanDB)

Queues random media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 801

#### (async) queueURL(socket, data)

Accepts new URL's to queue from the client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the URL from
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 96

#### (async) queueUserPlaylist(socket, data, userDB, chanDB)

Queues an entire user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 587

#### (async) refreshCommands()

Reloads toke commands from DB into RAM-based toke command store

Source:
  - app/channel/tokebot.js, line 59

#### refreshNextTimer(volatile)

Calculates next item to play, and sets timer to play it at it's scheduled start

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`volatile` | Boolean | false | Disables DB Transactions if true

Source:
  - app/channel/media/queue.js, line 442

#### (async) rehydrateQueue(chanDB)

Rehydrates media schedule from DB

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1640

#### relayChannelAnnouncement(msg, links)

Broadcasts announcement to a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 305

#### relayChat(user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given channel

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`chan` | String |  | Channel to broadcast message within
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 179

#### relayChatObject(chan, chat)

Relays an existing chat object to a channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`chan` | String | Channel to broadcast message within
`chat` | chat | Chat Object representing the message to broadcast to the given channel

Source:
  - app/channel/chatHandler.js, line 188

#### relayGlobalChat(user, flair, highLevel, msg, type, links)

Creates a new chatObject and relays the resulting message to the entire server

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 237

#### relayGlobalChatObject(chat)

Relays an existing chat object to the entire server

##### Parameters:

Name | Type | Description
--- | --- | ---
`chat` | chat | Chat Object representing the message to broadcast throughout the server

Source:
  - app/channel/chatHandler.js, line 245

#### relayGlobalTokeWhisper(msg, links)

Broadcasts toke whisper to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 286

#### relayPrivateChat(socket, user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending a message to (sounds menacing, huh?)
`user` | String | Originating user
`flair` | String | Flair ID to mark chat with
`highLevel` | Number | High Level to mark chat with
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`chan` | String | Channel to broadcast message within
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 215

#### relayPrivateChatObject(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 224

#### relayServerAnnouncement(msg, links)

Broadcasts announcement to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 296

#### relayTokeCallout(msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 268

#### relayTokeWhisper(socket, msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending the whisper to
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 277

#### relayUserChat(socket, msg, type, links)

Relays a chat message from a user to the rest of the channel based on socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 257

#### (async) removeMedia(uuid, socket, chanDB, noScheduling) → {Media}

Removes a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`uuid` | String |  | UUID of item to reschedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`noScheduling` | Boolean | false | Disables schedule timer refresh if true

Source:
  - app/channel/media/queue.js, line 649

##### Returns:

Deleted Media Item

Type
  Media

#### (async) removeRange(start, end, socket, noUnfinished)

Removes range of media items from the queue

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (millis)
`end` | Number |  | End date by JS Epoch (millis)
`socket` | Socket |  | Requesting Socket
`noUnfinished` | Boolean | false | Set to true to include items that may be currently playing

Source:
  - app/channel/media/queue.js, line 492

#### (async) renameChannelPlaylist(socket, data, chanDB)

Renames a channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 855

#### renameChannelPlaylistValidator(socket, data) → {String}

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 170

##### Returns:

returns escaped/trimmed name upon success

Type
  String

#### (async) renameUserPlaylist(socket, data, userDB)

Renames a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 912

#### (async) rescheduleMedia(uuid, start, socket, chanDB)

Reschedules a media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule
`start` | Number | New start time by JS Epoch (Millis)
`socket` | Socket | Requesting Socket
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/queue.js, line 544

#### resetToke()

Resets toke cooldowns early upon authorized request

Source:
  - app/channel/tokebot.js, line 222

#### sanatizeCommand(commandObj) → {Boolean}

Sanatizes and Validates a single user chat message/command

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 82

##### Returns:

false if Command/Message is too long to send

Type
  Boolean

#### (async) scheduleMedia(media, socket, chanDB, force, volatile, startVolatile, saveLate, noSave)

Schedules a Media Item This is a fun method and I think it deserves it's own little explination... Since we're working with a time based schedule, using start epochs as keys for our iterable seemed the best option I don't want to store everything in a sparse array because that *feels* icky, and would probably be a pain in the ass. Maps seem like a good choice, if it wheren't for the issue of keeping them ordered... That's where this comes in. You see if we temporarily store it in a sparse array and convert into a map, we can quickly and easily create a properly sorted schedule map that, out side of adding items, behaves normally. Also a note on preformance: While .forEach ONLY runs through populated items in sparse arrays, many JS implementations run through them in the background, simply skipping them before executing the provided function. Looping through object.keys(arr), however, avoids this entirely, since it ONLY loops through defiened items within the array. No skipped empties for your runtime to worry about. Even more preformance benefits can be had by using a real for loop on the arrays keys, skipping the overhead of forEach entirely. This might seem gross but it completely avoids the computational workload of a sorting algo, especially when you consider that, no matter what, re-ordering the schedule map would've required us to iterate through and rebuild the map anyways... Also it looks like due to implementation limitations, epochs stored as MS are too large for array elements, so we store them there as seconds. This also means that our current implementation will break exactly on unix epoch 4294967295 (Feb 7, 2106 6:28:15 AM UTC) Hopefully javascript arrays will allow for larger lengths by then. If not blame the W3C :P If for some reason they haven't and we're not dead, we could probably implement an object that wraps a 2d array and set/gets it using modulo/devision/multiplication Further Reading: https://stackoverflow.com/questions/59480871/foreach-vs-object-keys-foreach-performance-on-sparse-arrays https://community.appsmith.com/content/blog/dark-side-foreach-why-you-should-think-twice-using-it

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`media` | Media |  | Media item to schedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`force` | Boolean | false | Ignore certain conditions that would prevent scehduling and play the bitch anyways, used for internal function calls
`volatile` | Boolean | false | Prevent DB Writes, used for internal function calls
`startVolatile` | Boolean | false | Runs refreshNextTimer calls without DB writes, used for internal function calls
`saveLate` | Boolean | false | Saves items even if they're about to, or have already started. Used for internal function calls
`noSave` | Boolean | false | Allows function to edit Channel Document, but not save. Used for internal function calls in which the channel document is passed through, but will be saved immediatly after the scheduleMedia() call.

Source:
  - app/channel/media/queue.js, line 819

#### (async) sendChanEmotes(chanDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 220

#### sendChat(commandObj)

Relays chat to channel via parent Chat Handler object

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 153

#### (async) sendClientMetadata(userDB, chanDB)

Sends glut of required initial metadata to the client upon a new connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 141

#### sendMedia(socket)

Send media update to a specific socket or broadcast it to the entire channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1550

#### (async) sendPersonalEmotes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 238

#### (async) sendSiteEmotes()

Send copy of site emotes to the user

Source:
  - app/channel/connectedUser.js, line 208

#### (async) sendUsedTokes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 256

#### (async) setFlair(socket, data)

Handles incoming client request to change flair

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 71

#### (async) setHighLevel(socket, data)

Handles incoming client request to change high level

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 95

#### socketCrawl(cb)

Iterates through all known connections for a given user, running them through a supplied callback function

##### Parameters:

Name | Type | Description
--- | --- | ---
`cb` | function | Callback to call against found sockets for a given user

Source:
  - app/channel/connectedUser.js, line 92

#### splitCommand(commandObj)

Splits raw chat/command data into seperate arrays, one by word-borders and words surrounded by word-borders These arrays are used to handle further command/chat processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 95

#### (async) start(mediaObj, timestamp, volatile)

Kicks off a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`mediaObj` | queuedMedia |  | Media object that's about to play
`timestamp` | Number |  | Media start timestamp in seconds
`volatile` | Boolean | false | Disables DB Transactions

Source:
  - app/channel/media/queue.js, line 998

#### stop(socket)

Stops currently playing media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1414

##### Returns:

returns false if there is nothing to stop

#### (async) stopMedia(socket)

Processes requests to stop currently playing media from client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we received the request from

Source:
  - app/channel/media/queue.js, line 159

#### (async) stopScheduleTimers(noArchive)

Clears and scheduling timers

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`noArchive` | Boolean | true | Disables Archiving

Source:
  - app/channel/media/queue.js, line 383

#### sync()

Sends a syncronization ping out to client Sockets and increments the tracked timestamp by the Synchronization Delta Called auto-magically by the Synchronization Timer

Source:
  - app/channel/media/queue.js, line 1066

#### (async) toggleLock(socket)

Handle client request to (un)lock queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket

Source:
  - app/channel/media/queue.js, line 270

#### tokeProcessor(commandObj) → {Boolean}

Processes toke commands from Command Pre-Processor

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request, passed down from the Command Pre-Processor

Source:
  - app/channel/tokebot.js, line 69

##### Returns:

True if the toke is an invalid toke command (tells Command Pre-Processor to send command as chat)

Type
  Boolean

#### updateFlair(flair)

Set flair for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`flair` | String | Flair string to update user's flair to

Source:
  - app/channel/connectedUser.js, line 273

#### updateHighLevel(highLevel)

Set high level for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`highLevel` | Number | Number to update user's high-level to

Source:
  - app/channel/connectedUser.js, line 284

#### (async) validateSocket(socket) → {Boolean}

Global server-side validation logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 110

##### Returns:

true on success

Type
  Boolean

## exports(server, chatHandler)

Class containing global server-side tokebot logic

## Constructor

#### new exports(server, chatHandler)

Instantiates a tokebot object

##### Parameters:

Name | Type | Description
--- | --- | ---
`server` | channelManager | Parent Server Object
`chatHandler` | chatHandler | Parent Chat Handler Object

Source:
  - app/channel/tokebot.js, line 26

### Methods

#### (async) addPersonalEmote(socket, data)

Handles incoming client request to add a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 123

#### (async) addToChannelPlaylist(socket, data, chanDB)

Adds media to channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 434

#### (async) addToPlaylistValidator(socket, URL) → {Array}

Validates client requests to add media to a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`URL` | String | URL String handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 116

##### Returns:

List of media objects which where added

Type
  Array

#### (async) addToUserPlaylist(socket, data, userDB)

Adds media to user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 485

#### (async) asyncFinisher()

This method seems to be a vestage from a bygone era. We should remove it after documenting shit. I would now, but I don't want to break shit in a comment-only commit.

Source:
  - app/channel/tokebot.js, line 194

#### (async) authSocket(socket) → {Mongoose.Document}

Global server-side authorization logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 152

##### Returns:

- Authorized User Document upon success

Type
  Mongoose.Document

#### (async) broadcastChanEmotes(chanDB)

Broadcasts channel emote list to connected users

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/activeChannel.js, line 140

#### (async) broadcastQueue(chanDB)

Broadcasts channel queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1573

#### (async) broadcastSiteEmotes()

Broadcast global emote list

Source:
  - app/channel/channelManager.js, line 297

#### broadcastUserList()

Broadcasts user list to all users

Source:
  - app/channel/activeChannel.js, line 117

#### (async) changeDefaultTitlesChannelPlaylist(socket, data, chanDB)

Changes default titles for a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 968

#### (async) changeDefaultTitlesUserPlaylist(socket, data, userDB)

Changes default titles for a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1008

#### changeDefaultTitlesValidator(data) → {Array}

Validates client requests to change default titles for a given playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 188

##### Returns:

Array of strings containing valid titles from the output

Type
  Array

#### clearChat(user, chan)

Clears chat for a given channel, targets specified user or entire channel if none found/specified.

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | User chats to clear
`chan` | String | Channel to broadcast message within

Source:
  - app/channel/chatHandler.js, line 320

#### cooldown()

Runs every second for 60 seconds after a toke

Source:
  - app/channel/tokebot.js, line 205

#### countdown()

Called each second during the toke. Handles decrementing the timer variable, and countdown end logic.

Source:
  - app/channel/tokebot.js, line 148

#### crawlConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 254

#### (async) createChannelPlaylist(socket, data, chanDB)

Creates a new channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 270

#### createPlaylistValidator(socket, data) → {Object}

Validates client requests to create a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 80

##### Returns:

returns validated titles

Type
  Object

#### (async) createUserPlaylist(socket, data, userDB)

Creates a new user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 319

#### defineListeners(socket)

Define Global Server-Side socket event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 200

#### defineListeners(socket)

Defines global server-side chat relay event listeners

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/chatHandler.js, line 49

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/playlistHandler.js, line 47

#### defineListeners(socket)

Defines server-side socket.io listeners for newly connected sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against

Source:
  - app/channel/media/queue.js, line 79

#### (async) deleteChannelPlaylist(socket, data, userDB)

Deletes a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 367

#### (async) deleteChannelPlaylistMedia(socket, data, chanDB)

Deletes media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1048

#### (async) deleteMedia(socket, data)

Processes client requests to delete queued media

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 178

#### (async) deletePersonalEmote(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 158

#### deletePlaylistMediaValidator(socket, data)

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 210

#### (async) deleteRange(socket, data)

Processes request to delete a range of media items from the queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 205

#### (async) deleteUserPlaylist(socket, data, chanDB)

Deletes a Channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 401

#### (async) deleteUserPlaylistMedia(socket, data, userDB)

Deletes media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 1097

#### disconnect(reason, type)

Disconnects all sockets for a given user

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`reason` | String |  | Reason for being disconnected
`type` | String | Disconnected | Disconnection Type

Source:
  - app/channel/connectedUser.js, line 129

#### emit(eventName, data)

Emits an event to all known sockets for a given user My brain keeps going back to using dynamic per-user namespaces for this but everytime i look into it I come to the conclusion that it's a bad idea, then I toy with making chans namespaces and using per-user channels for this, but what of gold or mod-only features? or games? No matter what it'd probably end up hacky, as namespaces where meant for splitting app logic not user comms (like rooms). at the end of the day there has to be some penance for decent multi-session handling on-top of a library that doesn't do it. Having to crawl through these sockets is that. Because the other ways seem more gross somehow.

##### Parameters:

Name | Type | Description
--- | --- | ---
`eventName` | String | Event name to emit to client sockets
`data` | Object | Data to emit to client sockets

Source:
  - app/channel/connectedUser.js, line 115

#### (async) end(quiet, noArchive, volatile, chanDB)

End currently playing media

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`quiet` | Boolean | false | Enable to prevent ending the media client-side
`noArchive` | Boolean | false | Enable to prevent ended media from being written to channel archive. Deletes media if Volatile is false
`volatile` | Boolean | false | Enable to prevent DB Transactions
`chanDB` | Mongoose.Document |  | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1099

#### (async) endLivestream(wasPlaying, chanDB)

Ends running Livestream

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1183

#### fromMedia(media, startTime, startTimeStamp) → {queuedMedia}

Creates a queuedMedia object from a media object

##### Parameters:

Name | Type | Description
--- | --- | ---
`media` | media | Media object to queue
`startTime` | Number | Start time formatted as a JS Epoch
`startTimeStamp` | Number | Start time stamp in seconds

Source:
  - app/channel/media/queuedMedia.js, line 62

##### Returns:

queuedMedia object created from given media object

Type
  queuedMedia

#### fromMediaArray(mediaList, start)

Converts array of media objects into array of queuedMedia objects

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaList` | Array | Array of media objects to queue
`start` | Number | Start time formatted as JS Epoch

Source:
  - app/channel/media/queuedMedia.js, line 82

##### Returns:

Array of converted queued media objects

#### genUUID()

Generates new unique identifier for queued media

Source:
  - app/channel/media/queuedMedia.js, line 103

#### (async) getActiveChan(socket) → {Object}

Gets active channel from a given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 174

##### Returns:

Object containing users active channel name and channel document object

Type
  Object

#### (async) getChannelPlaylists(socket, chanDB)

Sends channel playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 228

#### getConnectedChannels(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 230

##### Returns:

returns related user info

#### getConnections(user, cb)

Iterates through connections by a given username, and runs them through a given callback function/method

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to crawl connections against
`cb` | function | Callback function to run active connections of a given user against

Source:
  - app/channel/channelManager.js, line 272

#### getEndTime(fullTime)

return the end time of a given queuedMedia object

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`fullTime` | boolean | false | Overrides early ends

Source:
  - app/channel/media/queuedMedia.js, line 112

##### Returns:

end time of given queuedMedia object

#### getItemAtEpoch(epoch) → {queuedMedia}

Gets a media item by epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis)

Source:
  - app/channel/media/queue.js, line 1471

##### Returns:

found media item

Type
  queuedMedia

#### getItemByUUID(uuid) → {queuedMedia}

Get Scheduled Item by UUID

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule

Source:
  - app/channel/media/queue.js, line 1535

##### Returns:

found item

Type
  queuedMedia

#### getItemsBetweenEpochs(start, end, noUnfinished) → {queuedMedia}

Returns scheduled media between two given datetimes

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (Millis)
`end` | Number |  | End date by JS Epoch (Millis)
`noUnfinished` | Boolean | false | Enable to include currently playing media

Source:
  - app/channel/media/queue.js, line 1446

##### Returns:

Found Media Objects

Type
  queuedMedia

#### getLastItem(epoch)

Gets last item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1490

##### Returns:

Last played item

#### getNextItem(epoch) → {queuedMedia}

Gets next item from a given epoch

##### Parameters:

Name | Type | Description
--- | --- | ---
`epoch` | Number | Date to check by JS Epoch (Millis), defaults to now

Source:
  - app/channel/media/queue.js, line 1520

##### Returns:

Next item on the schedule

Type
  queuedMedia

#### getSocketInfo(socket)

Pulls user information by socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check

Source:
  - app/channel/channelManager.js, line 220

##### Returns:

returns related user info

#### getStart(start)

Validates start times, and replaces bad ones with 5ms in the future

##### Parameters:

Name | Type | Description
--- | --- | ---
`start` | Number | Start time to validate by JS Epoch (millis)

Source:
  - app/channel/media/queue.js, line 407

##### Returns:

Start time as JS Epoch (millis)

#### (async) getUserPlaylists(socket, userDB)

Sends user playlist data to a requesting socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`userDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 248

#### (async) goLive(socket, data)

Handle client request to start an HLS live stream

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 289

#### handleChat(socket, data)

Handles incoming chat messages from client connections

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 62

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections to the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 53

#### (async) handleConnection(socket)

Handles global server-side initialization for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 57

#### (async) handleConnection(userDB, chanDB, socket)

Handles server-side initialization for new connections from a specific user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access
`socket` | Socket | Requesting Socket

Source:
  - app/channel/connectedUser.js, line 63

#### handleDisconnect(socket)

Handles server-side initialization for disconnecting from the channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/activeChannel.js, line 92

#### handleDisconnect(socket, reason)

Global server-side logic for handling disconncted sockets

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket to check
`reason` | String | Reason for disconnection

Source:
  - app/channel/channelManager.js, line 210

#### (async) handleRawRefresh(mediaObj) → {queuedMedia}

Refreshes expired raw links before media plays

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 978

##### Returns:

passes through Media object with updated link upon success

Type
  queuedMedia

#### kickConnections(user, reason)

Kicks a user from all channels by username

##### Parameters:

Name | Type | Description
--- | --- | ---
`user` | String | Username to kick from the server
`reason` | String | Reason for kick

Source:
  - app/channel/channelManager.js, line 289

#### (async) livestreamOverwriteSchedule(wasPlaying, chanDB)

Overwrites livestream over scheduled media content after it has ended

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1239

#### (async) livestreamPushbackSchedule(wasPlaying, chanDB)

Pushes back any missed content scheduled during Livestream after Livestream has ended.

##### Parameters:

Name | Type | Description
--- | --- | ---
`wasPlaying` | queuedMedia | Media object that was playing while we started the Livestream
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1328

#### (async) markLinks(commandObj)

Iterates through links in message and marks them by link type for later use by client-side post-processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 126

#### (async) moveMedia(socket, data)

Processes request to move queued media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 238

#### (async) preSwitch(mediaObj)

Called 10 seconds before media begins to play

##### Parameters:

Name | Type | Description
--- | --- | ---
`mediaObj` | queuedMedia | Media object that's about to play

Source:
  - app/channel/media/queue.js, line 969

#### (async) prepMessage(commandObj)

Re-creates message string from processed Command Array

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 142

#### (async) prepQueue(chanDB)

Prepares channel queue for network transmission

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1582

##### Returns:

de-hydrated scehdule information

#### (async) preprocess(socket, data)

Ingests a command/chat request from Chat Handler and pre-processes and processes it accordingly

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/commandPreprocessor.js, line 47

#### (async) processServerCommand(commandObj)

Uses the server's Command Processor object to process the chat/command request.

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 105

#### (async) queueChannelPlaylist(socket, data, chanDB)

Queues an entire channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 533

#### (async) queueFromChannelPlaylist(socket, data, chanDB)

Queues media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 646

#### queueFromChannelPlaylistValidator(socket, data) → {Number}

Validates client requests to queue media from a playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 151

##### Returns:

returns validated start time on success

Type
  Number

#### (async) queueFromUserPlaylist(socket, data, userDB, chanDB)

Queues media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 697

#### (async) queueRandomFromChannelPlaylist(socket, data, chanDB)

Queues random media from a given channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 753

#### (async) queueRandomFromUserPlaylist(socket, data, userDB, chanDB)

Queues random media from a given user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 801

#### (async) queueURL(socket, data)

Accepts new URL's to queue from the client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the URL from
`data` | Object | Event payload

Source:
  - app/channel/media/queue.js, line 96

#### (async) queueUserPlaylist(socket, data, userDB, chanDB)

Queues an entire user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 587

#### (async) refreshCommands()

Reloads toke commands from DB into RAM-based toke command store

Source:
  - app/channel/tokebot.js, line 59

#### refreshNextTimer(volatile)

Calculates next item to play, and sets timer to play it at it's scheduled start

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`volatile` | Boolean | false | Disables DB Transactions if true

Source:
  - app/channel/media/queue.js, line 442

#### (async) rehydrateQueue(chanDB)

Rehydrates media schedule from DB

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Pass through Channel Document to save on DB Transactions

Source:
  - app/channel/media/queue.js, line 1640

#### relayChannelAnnouncement(msg, links)

Broadcasts announcement to a given channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 305

#### relayChat(user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given channel

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`chan` | String |  | Channel to broadcast message within
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 179

#### relayChatObject(chan, chat)

Relays an existing chat object to a channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`chan` | String | Channel to broadcast message within
`chat` | chat | Chat Object representing the message to broadcast to the given channel

Source:
  - app/channel/chatHandler.js, line 188

#### relayGlobalChat(user, flair, highLevel, msg, type, links)

Creates a new chatObject and relays the resulting message to the entire server

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`user` | String |  | Originating user
`flair` | String |  | Flair ID to mark chat with
`highLevel` | Number |  | High Level to mark chat with
`msg` | String |  | Message Text Content
`type` | String | chat | Message Type, used for client-side chat post-processing.
`links` | Array |  | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 237

#### relayGlobalChatObject(chat)

Relays an existing chat object to the entire server

##### Parameters:

Name | Type | Description
--- | --- | ---
`chat` | chat | Chat Object representing the message to broadcast throughout the server

Source:
  - app/channel/chatHandler.js, line 245

#### relayGlobalTokeWhisper(msg, links)

Broadcasts toke whisper to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 286

#### relayPrivateChat(socket, user, flair, highLevel, msg, type, chan, links)

Creates a new chatObject and relays the resulting message to the given socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending a message to (sounds menacing, huh?)
`user` | String | Originating user
`flair` | String | Flair ID to mark chat with
`highLevel` | Number | High Level to mark chat with
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`chan` | String | Channel to broadcast message within
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 215

#### relayPrivateChatObject(socket, data)

Handles incoming client request to delete a personal emote

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 224

#### relayServerAnnouncement(msg, links)

Broadcasts announcement to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 296

#### relayTokeCallout(msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 268

#### relayTokeWhisper(socket, msg, links)

Broadcasts toke callout to the server

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're sending the whisper to
`msg` | String | Message Text Content
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 277

#### relayUserChat(socket, msg, type, links)

Relays a chat message from a user to the rest of the channel based on socket

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`msg` | String | Message Text Content
`type` | String | Message Type, used for client-side chat post-processing.
`links` | Array | Array of URLs/Links to hand to the client-side chat post-processor to inject into the final message.

Source:
  - app/channel/chatHandler.js, line 257

#### (async) removeMedia(uuid, socket, chanDB, noScheduling) → {Media}

Removes a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`uuid` | String |  | UUID of item to reschedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`noScheduling` | Boolean | false | Disables schedule timer refresh if true

Source:
  - app/channel/media/queue.js, line 649

##### Returns:

Deleted Media Item

Type
  Media

#### (async) removeRange(start, end, socket, noUnfinished)

Removes range of media items from the queue

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`start` | Number |  | Start date by JS Epoch (millis)
`end` | Number |  | End date by JS Epoch (millis)
`socket` | Socket |  | Requesting Socket
`noUnfinished` | Boolean | false | Set to true to include items that may be currently playing

Source:
  - app/channel/media/queue.js, line 492

#### (async) renameChannelPlaylist(socket, data, chanDB)

Renames a channel playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`chanDB` | Mongoose.Document | Channel Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 855

#### renameChannelPlaylistValidator(socket, data) → {String}

Validates client requests to rename the playlist validator

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Newly connected socket to define listeners against
`data` | Object | Data handed over from the client

Source:
  - app/channel/media/playlistHandler.js, line 170

##### Returns:

returns escaped/trimmed name upon success

Type
  String

#### (async) renameUserPlaylist(socket, data, userDB)

Renames a user playlist

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket
`data` | Object | Data handed over from the client
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/media/playlistHandler.js, line 912

#### (async) rescheduleMedia(uuid, start, socket, chanDB)

Reschedules a media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`uuid` | String | UUID of item to reschedule
`start` | Number | New start time by JS Epoch (Millis)
`socket` | Socket | Requesting Socket
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/media/queue.js, line 544

#### resetToke()

Resets toke cooldowns early upon authorized request

Source:
  - app/channel/tokebot.js, line 222

#### sanatizeCommand(commandObj) → {Boolean}

Sanatizes and Validates a single user chat message/command

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 82

##### Returns:

false if Command/Message is too long to send

Type
  Boolean

#### (async) scheduleMedia(media, socket, chanDB, force, volatile, startVolatile, saveLate, noSave)

Schedules a Media Item This is a fun method and I think it deserves it's own little explination... Since we're working with a time based schedule, using start epochs as keys for our iterable seemed the best option I don't want to store everything in a sparse array because that *feels* icky, and would probably be a pain in the ass. Maps seem like a good choice, if it wheren't for the issue of keeping them ordered... That's where this comes in. You see if we temporarily store it in a sparse array and convert into a map, we can quickly and easily create a properly sorted schedule map that, out side of adding items, behaves normally. Also a note on preformance: While .forEach ONLY runs through populated items in sparse arrays, many JS implementations run through them in the background, simply skipping them before executing the provided function. Looping through object.keys(arr), however, avoids this entirely, since it ONLY loops through defiened items within the array. No skipped empties for your runtime to worry about. Even more preformance benefits can be had by using a real for loop on the arrays keys, skipping the overhead of forEach entirely. This might seem gross but it completely avoids the computational workload of a sorting algo, especially when you consider that, no matter what, re-ordering the schedule map would've required us to iterate through and rebuild the map anyways... Also it looks like due to implementation limitations, epochs stored as MS are too large for array elements, so we store them there as seconds. This also means that our current implementation will break exactly on unix epoch 4294967295 (Feb 7, 2106 6:28:15 AM UTC) Hopefully javascript arrays will allow for larger lengths by then. If not blame the W3C :P If for some reason they haven't and we're not dead, we could probably implement an object that wraps a 2d array and set/gets it using modulo/devision/multiplication Further Reading: https://stackoverflow.com/questions/59480871/foreach-vs-object-keys-foreach-performance-on-sparse-arrays https://community.appsmith.com/content/blog/dark-side-foreach-why-you-should-think-twice-using-it

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`media` | Media |  | Media item to schedule
`socket` | Socket |  | Requesting Socket
`chanDB` | Mongoose.Document |  | Channnel Document Passthrough to save on DB Access
`force` | Boolean | false | Ignore certain conditions that would prevent scehduling and play the bitch anyways, used for internal function calls
`volatile` | Boolean | false | Prevent DB Writes, used for internal function calls
`startVolatile` | Boolean | false | Runs refreshNextTimer calls without DB writes, used for internal function calls
`saveLate` | Boolean | false | Saves items even if they're about to, or have already started. Used for internal function calls
`noSave` | Boolean | false | Allows function to edit Channel Document, but not save. Used for internal function calls in which the channel document is passed through, but will be saved immediatly after the scheduleMedia() call.

Source:
  - app/channel/media/queue.js, line 819

#### (async) sendChanEmotes(chanDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 220

#### sendChat(commandObj)

Relays chat to channel via parent Chat Handler object

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 153

#### (async) sendClientMetadata(userDB, chanDB)

Sends glut of required initial metadata to the client upon a new connection

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access
`chanDB` | Mongoose.Document | Channnel Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 141

#### sendMedia(socket)

Send media update to a specific socket or broadcast it to the entire channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1550

#### (async) sendPersonalEmotes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 238

#### (async) sendSiteEmotes()

Send copy of site emotes to the user

Source:
  - app/channel/connectedUser.js, line 208

#### (async) sendUsedTokes(userDB)

Send copy of channel emotes to the user

##### Parameters:

Name | Type | Description
--- | --- | ---
`userDB` | Mongoose.Document | User Document Passthrough to save on DB Access

Source:
  - app/channel/connectedUser.js, line 256

#### (async) setFlair(socket, data)

Handles incoming client request to change flair

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 71

#### (async) setHighLevel(socket, data)

Handles incoming client request to change high level

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we're receiving the request from
`data` | Object | Event payload

Source:
  - app/channel/chatHandler.js, line 95

#### socketCrawl(cb)

Iterates through all known connections for a given user, running them through a supplied callback function

##### Parameters:

Name | Type | Description
--- | --- | ---
`cb` | function | Callback to call against found sockets for a given user

Source:
  - app/channel/connectedUser.js, line 92

#### splitCommand(commandObj)

Splits raw chat/command data into seperate arrays, one by word-borders and words surrounded by word-borders These arrays are used to handle further command/chat processing

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request

Source:
  - app/channel/commandPreprocessor.js, line 95

#### (async) start(mediaObj, timestamp, volatile)

Kicks off a media item

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`mediaObj` | queuedMedia |  | Media object that's about to play
`timestamp` | Number |  | Media start timestamp in seconds
`volatile` | Boolean | false | Disables DB Transactions

Source:
  - app/channel/media/queue.js, line 998

#### stop(socket)

Stops currently playing media item

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/media/queue.js, line 1414

##### Returns:

returns false if there is nothing to stop

#### (async) stopMedia(socket)

Processes requests to stop currently playing media from client

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Socket we received the request from

Source:
  - app/channel/media/queue.js, line 159

#### (async) stopScheduleTimers(noArchive)

Clears and scheduling timers

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`noArchive` | Boolean | true | Disables Archiving

Source:
  - app/channel/media/queue.js, line 383

#### sync()

Sends a syncronization ping out to client Sockets and increments the tracked timestamp by the Synchronization Delta Called auto-magically by the Synchronization Timer

Source:
  - app/channel/media/queue.js, line 1066

#### (async) toggleLock(socket)

Handle client request to (un)lock queue

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting socket

Source:
  - app/channel/media/queue.js, line 270

#### tokeProcessor(commandObj) → {Boolean}

Processes toke commands from Command Pre-Processor

##### Parameters:

Name | Type | Description
--- | --- | ---
`commandObj` | Object | Object representing a single given command/chat request, passed down from the Command Pre-Processor

Source:
  - app/channel/tokebot.js, line 69

##### Returns:

True if the toke is an invalid toke command (tells Command Pre-Processor to send command as chat)

Type
  Boolean

#### updateFlair(flair)

Set flair for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`flair` | String | Flair string to update user's flair to

Source:
  - app/channel/connectedUser.js, line 273

#### updateHighLevel(highLevel)

Set high level for a given user and broadcast update to clients

##### Parameters:

Name | Type | Description
--- | --- | ---
`highLevel` | Number | Number to update user's high-level to

Source:
  - app/channel/connectedUser.js, line 284

#### (async) validateSocket(socket) → {Boolean}

Global server-side validation logic for new connections to any channel

##### Parameters:

Name | Type | Description
--- | --- | ---
`socket` | Socket | Requesting Socket

Source:
  - app/channel/channelManager.js, line 110

##### Returns:

true on success

Type
  Boolean