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:
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:
(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 |
(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 |
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 |
(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:
(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:
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:
(async) broadcastQueue(chanDB)
Broadcasts channel queue
Parameters:
| Name | Type | Description |
|---|---|---|
chanDB |
Mongoose.Document | Pass through Channel Document to save on DB Transactions |
- Source:
(async) broadcastSiteEmotes()
Broadcast global emote list
- Source:
broadcastUserList()
Broadcasts user list to all users
- Source:
(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 |
(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 |
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 |
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:
cooldown()
Runs every second for 60 seconds after a toke
- Source:
countdown()
Called each second during the toke. Handles decrementing the timer variable, and countdown end logic.
- Source:
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:
(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 |
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 |
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 |
defineListeners(socket)
Define Global Server-Side socket event listeners
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
Socket | Socket to check |
- Source:
defineListeners(socket)
Defines global server-side chat relay event listeners
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
Socket | Requesting Socket |
- Source:
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 |
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:
(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 |
(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 |
(async) deleteMedia(socket, data)
Processes client requests to delete queued media
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
Socket | Requesting socket |
data |
Object | Event payload |
- Source:
(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:
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 |
(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:
(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 |
(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 |
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:
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:
(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:
(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:
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:
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:
Returns:
Array of converted queued media objects
genUUID()
Generates new unique identifier for queued media
- Source:
(async) getActiveChan(socket) → {Object}
Gets active channel from a given socket
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
Socket | Socket to check |
- Source:
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 |
getConnectedChannels(socket)
Pulls user information by socket
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
Socket | Socket to check |
- Source:
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:
getEndTime(fullTime)
return the end time of a given queuedMedia object
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
fullTime |
boolean | false | Overrides early ends |
- Source:
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:
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:
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:
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:
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:
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:
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:
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 |
(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:
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:
(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:
(async) handleConnection(socket)
Handles global server-side initialization for new connections to any channel
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
Socket | Requesting Socket |
- Source:
(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:
handleDisconnect(socket)
Handles server-side initialization for disconnecting from the channel
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
Socket | Requesting Socket |
- Source:
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:
(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:
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:
(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:
(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:
(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 |
(async) moveMedia(socket, data)
Processes request to move queued media item
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
Socket | Requesting socket |
data |
Object | Event payload |
- Source:
(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:
(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 |
(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:
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 |
(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 |
(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 |
(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 |
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 |
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 |
(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 |
(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 |
(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:
(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 |
(async) refreshCommands()
Reloads toke commands from DB into RAM-based toke command store
- Source:
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:
(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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
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:
(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:
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:
(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 |
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 |
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 |
(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:
resetToke()
Resets toke cooldowns early upon authorized request
- Source:
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 |
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:
(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:
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 |
(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:
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:
(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:
(async) sendSiteEmotes()
Send copy of site emotes to the user
- Source:
(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:
(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:
(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:
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:
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 |
(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:
stop(socket)
Stops currently playing media item
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
Socket | Requesting Socket |
- Source:
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:
(async) stopScheduleTimers(noArchive)
Clears and scheduling timers
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
noArchive |
Boolean | true | Disables Archiving |
- Source:
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:
(async) toggleLock(socket)
Handle client request to (un)lock queue
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
Socket | Requesting socket |
- Source:
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:
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:
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:
(async) validateSocket(socket) → {Boolean}
Global server-side validation logic for new connections to any channel
Parameters:
| Name | Type | Description |
|---|---|---|
socket |
Socket | Requesting Socket |
- Source:
Returns:
true on success
- Type
- Boolean