canopy/www/doc/server/connectedUser.html

2450 lines
31 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>JSDoc: Class: connectedUser</title>
<script src="scripts/prettify/prettify.js"> </script>
<script src="scripts/prettify/lang-css.js"> </script>
<!--[if lt IE 9]>
<script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
<link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>
<body>
<div id="main">
<h1 class="page-title">Class: connectedUser</h1>
<section>
<header>
<h2><span class="attribs"><span class="type-signature"></span></span>connectedUser<span class="signature">(userDB, chanRank, channel, socket)</span><span class="type-signature"></span></h2>
<div class="class-description">Class representing a single user connected to a channel</div>
</header>
<article>
<div class="container-overview">
<h2>Constructor</h2>
<h4 class="name" id="connectedUser"><span class="type-signature"></span>new connectedUser<span class="signature">(userDB, chanRank, channel, socket)</span><span class="type-signature"></span></h4>
<div class="description">
Instantiates a connectedUser object
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>userDB</code></td>
<td class="type">
<span class="param-type">Mongoose.Document</span>
</td>
<td class="description last">User document to re-hydrate user from</td>
</tr>
<tr>
<td class="name"><code>chanRank</code></td>
<td class="type">
<span class="param-type">PemissionModel.chanRank</span>
</td>
<td class="description last">Enum representing user channel rank</td>
</tr>
<tr>
<td class="name"><code>channel</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Channel the user is connecting to</td>
</tr>
<tr>
<td class="name"><code>socket</code></td>
<td class="type">
<span class="param-type">Socket</span>
</td>
<td class="description last">Socket associated with the users connection</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line28">line 28</a>
</li></ul></dd>
</dl>
</div>
<h3 class="subsection-title">Members</h3>
<h4 class="name" id="chanRank"><span class="type-signature"></span>chanRank<span class="type-signature"></span></h4>
<div class="description">
User Channel-Rank
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line76">line 76</a>
</li></ul></dd>
</dl>
<h4 class="name" id="channel"><span class="type-signature"></span>channel<span class="type-signature"></span></h4>
<div class="description">
Connected Channel
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line81">line 81</a>
</li></ul></dd>
</dl>
<h4 class="name" id="flair"><span class="type-signature"></span>flair<span class="type-signature"></span></h4>
<div class="description">
User Flair
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line63">line 63</a>
</li></ul></dd>
</dl>
<h4 class="name" id="flair"><span class="type-signature"></span>flair<span class="type-signature"></span></h4>
<div class="description">
User Flair
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line70">line 70</a>
</li></ul></dd>
</dl>
<h4 class="name" id="highLevel"><span class="type-signature"></span>highLevel<span class="type-signature"></span></h4>
<div class="description">
User High-Level
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line55">line 55</a>
</li></ul></dd>
</dl>
<h4 class="name" id="id"><span class="type-signature"></span>id<span class="type-signature"></span></h4>
<div class="description">
User ID Number
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line40">line 40</a>
</li></ul></dd>
</dl>
<h4 class="name" id="rank"><span class="type-signature"></span>rank<span class="type-signature"></span></h4>
<div class="description">
User Rank
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line50">line 50</a>
</li></ul></dd>
</dl>
<h4 class="name" id="sockets"><span class="type-signature"></span>sockets<span class="type-signature"></span></h4>
<div class="description">
List of active sockets to current channel
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line86">line 86</a>
</li></ul></dd>
</dl>
<h4 class="name" id="user"><span class="type-signature"></span>user<span class="type-signature"></span></h4>
<div class="description">
User Name
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line45">line 45</a>
</li></ul></dd>
</dl>
<h3 class="subsection-title">Methods</h3>
<h4 class="name" id="disconnect"><span class="type-signature"></span>disconnect<span class="signature">(reason, type)</span><span class="type-signature"></span></h4>
<div class="description">
Disconnects all sockets for a given user
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>reason</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="default">
</td>
<td class="description last">Reason for being disconnected</td>
</tr>
<tr>
<td class="name"><code>type</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="default">
Disconnected
</td>
<td class="description last">Disconnection Type</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line161">line 161</a>
</li></ul></dd>
</dl>
<h4 class="name" id="emit"><span class="type-signature"></span>emit<span class="signature">(eventName, data)</span><span class="type-signature"></span></h4>
<div class="description">
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.
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>eventName</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Event name to emit to client sockets</td>
</tr>
<tr>
<td class="name"><code>data</code></td>
<td class="type">
<span class="param-type">Object</span>
</td>
<td class="description last">Data to emit to client sockets</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line147">line 147</a>
</li></ul></dd>
</dl>
<h4 class="name" id="handleConnection"><span class="type-signature">(async) </span>handleConnection<span class="signature">(userDB, chanDB, socket)</span><span class="type-signature"></span></h4>
<div class="description">
Handles server-side initialization for new connections from a specific user
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>userDB</code></td>
<td class="type">
<span class="param-type">Mongoose.Document</span>
</td>
<td class="description last">User Document Passthrough to save on DB Access</td>
</tr>
<tr>
<td class="name"><code>chanDB</code></td>
<td class="type">
<span class="param-type">Mongoose.Document</span>
</td>
<td class="description last">Channnel Document Passthrough to save on DB Access</td>
</tr>
<tr>
<td class="name"><code>socket</code></td>
<td class="type">
<span class="param-type">Socket</span>
</td>
<td class="description last">Requesting Socket</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line95">line 95</a>
</li></ul></dd>
</dl>
<h4 class="name" id="sendChanEmotes"><span class="type-signature">(async) </span>sendChanEmotes<span class="signature">(chanDB)</span><span class="type-signature"></span></h4>
<div class="description">
Send copy of channel emotes to the user
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>chanDB</code></td>
<td class="type">
<span class="param-type">Mongoose.Document</span>
</td>
<td class="description last">Channnel Document Passthrough to save on DB Access</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line252">line 252</a>
</li></ul></dd>
</dl>
<h4 class="name" id="sendClientMetadata"><span class="type-signature">(async) </span>sendClientMetadata<span class="signature">(userDB, chanDB)</span><span class="type-signature"></span></h4>
<div class="description">
Sends glut of required initial metadata to the client upon a new connection
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>userDB</code></td>
<td class="type">
<span class="param-type">Mongoose.Document</span>
</td>
<td class="description last">User Document Passthrough to save on DB Access</td>
</tr>
<tr>
<td class="name"><code>chanDB</code></td>
<td class="type">
<span class="param-type">Mongoose.Document</span>
</td>
<td class="description last">Channnel Document Passthrough to save on DB Access</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line173">line 173</a>
</li></ul></dd>
</dl>
<h4 class="name" id="sendPersonalEmotes"><span class="type-signature">(async) </span>sendPersonalEmotes<span class="signature">(userDB)</span><span class="type-signature"></span></h4>
<div class="description">
Send copy of channel emotes to the user
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>userDB</code></td>
<td class="type">
<span class="param-type">Mongoose.Document</span>
</td>
<td class="description last">User Document Passthrough to save on DB Access</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line270">line 270</a>
</li></ul></dd>
</dl>
<h4 class="name" id="sendSiteEmotes"><span class="type-signature">(async) </span>sendSiteEmotes<span class="signature">()</span><span class="type-signature"></span></h4>
<div class="description">
Send copy of site emotes to the user
</div>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line240">line 240</a>
</li></ul></dd>
</dl>
<h4 class="name" id="sendUsedTokes"><span class="type-signature">(async) </span>sendUsedTokes<span class="signature">(userDB)</span><span class="type-signature"></span></h4>
<div class="description">
Send copy of channel emotes to the user
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>userDB</code></td>
<td class="type">
<span class="param-type">Mongoose.Document</span>
</td>
<td class="description last">User Document Passthrough to save on DB Access</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line288">line 288</a>
</li></ul></dd>
</dl>
<h4 class="name" id="socketCrawl"><span class="type-signature"></span>socketCrawl<span class="signature">(cb)</span><span class="type-signature"></span></h4>
<div class="description">
Iterates through all known connections for a given user, running them through a supplied callback function
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>cb</code></td>
<td class="type">
<span class="param-type">function</span>
</td>
<td class="description last">Callback to call against found sockets for a given user</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line124">line 124</a>
</li></ul></dd>
</dl>
<h4 class="name" id="updateFlair"><span class="type-signature"></span>updateFlair<span class="signature">(flair)</span><span class="type-signature"></span></h4>
<div class="description">
Set flair for a given user and broadcast update to clients
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>flair</code></td>
<td class="type">
<span class="param-type">String</span>
</td>
<td class="description last">Flair string to update user's flair to</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line305">line 305</a>
</li></ul></dd>
</dl>
<h4 class="name" id="updateHighLevel"><span class="type-signature"></span>updateHighLevel<span class="signature">(highLevel)</span><span class="type-signature"></span></h4>
<div class="description">
Set high level for a given user and broadcast update to clients
</div>
<h5>Parameters:</h5>
<table class="params">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th class="last">Description</th>
</tr>
</thead>
<tbody>
<tr>
<td class="name"><code>highLevel</code></td>
<td class="type">
<span class="param-type">Number</span>
</td>
<td class="description last">Number to update user's high-level to</td>
</tr>
</tbody>
</table>
<dl class="details">
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="app_channel_connectedUser.js.html">app/channel/connectedUser.js</a>, <a href="app_channel_connectedUser.js.html#line316">line 316</a>
</li></ul></dd>
</dl>
</article>
</section>
</div>
<nav>
<h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="activeChannel.html">activeChannel</a></li><li><a href="channelManager.html">channelManager</a></li><li><a href="chat.html">chat</a></li><li><a href="chatBuffer.html">chatBuffer</a></li><li><a href="chatHandler.html">chatHandler</a></li><li><a href="commandPreprocessor.html">commandPreprocessor</a></li><li><a href="commandProcessor.html">commandProcessor</a></li><li><a href="connectedUser.html">connectedUser</a></li><li><a href="media.html">media</a></li><li><a href="playlistHandler.html">playlistHandler</a></li><li><a href="queue.html">queue</a></li><li><a href="queuedMedia.html">queuedMedia</a></li><li><a href="tokebot.html">tokebot</a></li></ul><h3>Global</h3><ul><li><a href="global.html#authenticateSession">authenticateSession</a></li><li><a href="global.html#cache">cache</a></li><li><a href="global.html#channelBanSchema">channelBanSchema</a></li><li><a href="global.html#channelPermissionSchema">channelPermissionSchema</a></li><li><a href="global.html#channelSchema">channelSchema</a></li><li><a href="global.html#chatSchema">chatSchema</a></li><li><a href="global.html#comparePassword">comparePassword</a></li><li><a href="global.html#consoleWarn">consoleWarn</a></li><li><a href="global.html#daysToExpire">daysToExpire</a></li><li><a href="global.html#dumpError">dumpError</a></li><li><a href="global.html#emailChangeSchema">emailChangeSchema</a></li><li><a href="global.html#emoteSchema">emoteSchema</a></li><li><a href="global.html#errorHandler">errorHandler</a></li><li><a href="global.html#errorMiddleware">errorMiddleware</a></li><li><a href="global.html#escapeRegex">escapeRegex</a></li><li><a href="global.html#exceptionHandler">exceptionHandler</a></li><li><a href="global.html#exceptionSmith">exceptionSmith</a></li><li><a href="global.html#failedAttempts">failedAttempts</a></li><li><a href="global.html#fetchMetadata">fetchMetadata</a></li><li><a href="global.html#fetchVideoMetadata">fetchVideoMetadata</a></li><li><a href="global.html#fetchYoutubeMetadata">fetchYoutubeMetadata</a></li><li><a href="global.html#fetchYoutubePlaylistMetadata">fetchYoutubePlaylistMetadata</a></li><li><a href="global.html#flairSchema">flairSchema</a></li><li><a href="global.html#genCaptcha">genCaptcha</a></li><li><a href="global.html#getLoginAttempts">getLoginAttempts</a></li><li><a href="global.html#getMediaType">getMediaType</a></li><li><a href="global.html#hashIP">hashIP</a></li><li><a href="global.html#hashPassword">hashPassword</a></li><li><a href="global.html#kickoff">kickoff</a></li><li><a href="global.html#killSession">killSession</a></li><li><a href="global.html#lifetime">lifetime</a></li><li><a href="global.html#localExceptionHandler">localExceptionHandler</a></li><li><a href="global.html#mailem">mailem</a></li><li><a href="global.html#markLink">markLink</a></li><li><a href="global.html#maxAttempts">maxAttempts</a></li><li><a href="global.html#mediaSchema">mediaSchema</a></li><li><a href="global.html#passwordResetSchema">passwordResetSchema</a></li><li><a href="global.html#permissionSchema">permissionSchema</a></li><li><a href="global.html#playlistMediaProperties">playlistMediaProperties</a></li><li><a href="global.html#playlistSchema">playlistSchema</a></li><li><a href="global.html#processExpiredAttempts">processExpiredAttempts</a></li><li><a href="global.html#queuedProperties">queuedProperties</a></li><li><a href="global.html#rankEnum">rankEnum</a></li><li><a href="global.html#refreshRawLink">refreshRawLink</a></li><li><a href="global.html#schedule">schedule</a></li><li><a href="global.html#securityCheck">securityCheck</a></li><li><a href="global.html#sendAddressVerification">sendAddressVerification</a></li><li><a href="global.html#socketCriticalExceptionHandler">socketCriticalExceptionHandler</a></li><li><a href="global.html#socketErrorHandler">socketErrorHandler</a></li><li><a href="global.html#socketExceptionHandler">socketExceptionHandler</a></li><li><a href="global.html#spent">spent</a></li><li><a href="global.html#statSchema">statSchema</a></li><li><a href="global.html#throttleAttempts">throttleAttempts</a></li><li><a href="global.html#tokeCommandSchema">tokeCommandSchema</a></li><li><a href="global.html#transporter">transporter</a></li><li><a href="global.html#typeEnum">typeEnum</a></li><li><a href="global.html#userBanSchema">userBanSchema</a></li><li><a href="global.html#userSchema">userSchema</a></li><li><a href="global.html#verify">verify</a></li><li><a href="global.html#yankMedia">yankMedia</a></li><li><a href="global.html#ytdlpFetch">ytdlpFetch</a></li></ul>
</nav>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc/jsdoc">JSDoc 4.0.4</a> on Sat Sep 06 2025 19:07:56 GMT-0400 (Eastern Daylight Time)
</footer>
<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>