Class: connectedUser

connectedUser(userDB, chanRank, channel, socket)

Class representing a single user connected to a channel

Constructor

new connectedUser(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:

Methods

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) 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:

(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:

(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:

(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:

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:

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: