UNPKG

bravey

Version:

A simple JavaScript NLP-like library to help you creating your own bot.

1,296 lines (354 loc) 17.7 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Class: InMemorySessionManager</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: InMemorySessionManager</h1> <section> <header> <h2> <span class="ancestors"><a href="Bravey.html">Bravey</a><a href="Bravey.SessionManager.html">.SessionManager</a>.</span>InMemorySessionManager</h2> </header> <article> <div class="container-overview"> <h4 class="name" id="InMemorySessionManager"><span class="type-signature"></span>new InMemorySessionManager<span class="signature">()</span><span class="type-signature"></span></h4> <div class="description"> A session manager to be used as sessionManager for <a href="Bravey.ContextManager.html">Bravey.ContextManager</a>. Stores session IDs in memory. </div> <h5>Parameters:</h5> <table class="params"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Attributes</th> <th class="last">Description</th> </tr> </thead> <tbody> <tr> <td class="name"><code>extensions.sessionLength</code></td> <td class="type"> <span class="param-type">Number</span> </td> <td class="attributes"> &lt;optional><br> </td> <td class="description last">Session duration in milliseconds. (default is 600000 - 10 minutes)</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="sessionmanagers_InMemorySessionManager.js.html">sessionmanagers/InMemorySessionManager.js</a>, <a href="sessionmanagers_InMemorySessionManager.js.html#line6">line 6</a> </li></ul></dd> </dl> </div> <h3 class="subsection-title">Methods</h3> <h4 class="name" id="clearData"><span class="type-signature"></span>clearData<span class="signature">(sessionid)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Empty context data for the specified session ID. Updates the user timestamp, preventing session expiring. </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>sessionid</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The session ID.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="sessionmanagers_InMemorySessionManager.js.html">sessionmanagers/InMemorySessionManager.js</a>, <a href="sessionmanagers_InMemorySessionManager.js.html#line91">line 91</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True if sessionid is found and context is set. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="getContext"><span class="type-signature"></span>getContext<span class="signature">(sessionid)</span><span class="type-signature"> &rarr; {Array.&lt;string>}</span></h4> <div class="description"> Get context for the specified session ID. </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>sessionid</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The session ID.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="sessionmanagers_InMemorySessionManager.js.html">sessionmanagers/InMemorySessionManager.js</a>, <a href="sessionmanagers_InMemorySessionManager.js.html#line104">line 104</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The related contexts. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array.&lt;string></span> </dd> </dl> <h4 class="name" id="getData"><span class="type-signature"></span>getData<span class="signature">(sessionid)</span><span class="type-signature"> &rarr; {Array.&lt;string>}</span></h4> <div class="description"> Get context data for the specified session ID. </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>sessionid</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The session ID.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="sessionmanagers_InMemorySessionManager.js.html">sessionmanagers/InMemorySessionManager.js</a>, <a href="sessionmanagers_InMemorySessionManager.js.html#line113">line 113</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The related data. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">Array.&lt;string></span> </dd> </dl> <h4 class="name" id="keepAlive"><span class="type-signature"></span>keepAlive<span class="signature">(sessionid)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Keep a session alive, resetting expiration time. </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>sessionid</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The session ID.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="sessionmanagers_InMemorySessionManager.js.html">sessionmanagers/InMemorySessionManager.js</a>, <a href="sessionmanagers_InMemorySessionManager.js.html#line50">line 50</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True if sessionid is found and kept alive. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="reserveSessionId"><span class="type-signature"></span>reserveSessionId<span class="signature">()</span><span class="type-signature"> &rarr; {string}</span></h4> <div class="description"> Reserves a new session ID. It also clear expired sessions. </div> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="sessionmanagers_InMemorySessionManager.js.html">sessionmanagers/InMemorySessionManager.js</a>, <a href="sessionmanagers_InMemorySessionManager.js.html#line34">line 34</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> The new session ID. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">string</span> </dd> </dl> <h4 class="name" id="setContext"><span class="type-signature"></span>setContext<span class="signature">(sessionid, contexttags)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Set context for the specified session ID. Updates the user timestamp, preventing session expiring. </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>sessionid</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The session ID.</td> </tr> <tr> <td class="name"><code>contexttags</code></td> <td class="type"> <span class="param-type">Array.&lt;string></span> </td> <td class="description last">The context tags to be set.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="sessionmanagers_InMemorySessionManager.js.html">sessionmanagers/InMemorySessionManager.js</a>, <a href="sessionmanagers_InMemorySessionManager.js.html#line64">line 64</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True if sessionid is found and context is set. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> <h4 class="name" id="setData"><span class="type-signature"></span>setData<span class="signature">(sessionid, data)</span><span class="type-signature"> &rarr; {boolean}</span></h4> <div class="description"> Set context data for the specified session ID. Updates the user timestamp, preventing session expiring. </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>sessionid</code></td> <td class="type"> <span class="param-type">string</span> </td> <td class="description last">The session ID.</td> </tr> <tr> <td class="name"><code>data</code></td> <td class="type"> <span class="param-type">Object</span> </td> <td class="description last">Key/value pair for data to be set.</td> </tr> </tbody> </table> <dl class="details"> <dt class="tag-source">Source:</dt> <dd class="tag-source"><ul class="dummy"><li> <a href="sessionmanagers_InMemorySessionManager.js.html">sessionmanagers/InMemorySessionManager.js</a>, <a href="sessionmanagers_InMemorySessionManager.js.html#line78">line 78</a> </li></ul></dd> </dl> <h5>Returns:</h5> <div class="param-desc"> True if sessionid is found and context is set. </div> <dl> <dt> Type </dt> <dd> <span class="param-type">boolean</span> </dd> </dl> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Classes</h3><ul><li><a href="Bravey.ApiAiAdapter.html">ApiAiAdapter</a></li><li><a href="Bravey.ContextManager.html">ContextManager</a></li><li><a href="Bravey.DocumentClassifier.html">DocumentClassifier</a></li><li><a href="Bravey.EMailEntityRecognizer.html">EMailEntityRecognizer</a></li><li><a href="Bravey.Filter.BasicFilter.html">BasicFilter</a></li><li><a href="Bravey.FreeTextEntityRecognizer.html">FreeTextEntityRecognizer</a></li><li><a href="Bravey.Language.EN.DateEntityRecognizer.html">DateEntityRecognizer</a></li><li><a href="Bravey.Language.EN.FreeTextEntityRecognizer.html">FreeTextEntityRecognizer</a></li><li><a href="Bravey.Language.EN.NumberEntityRecognizer.html">NumberEntityRecognizer</a></li><li><a href="Bravey.Language.EN.Stemmer.html">Stemmer</a></li><li><a href="Bravey.Language.EN.TimeEntityRecognizer.html">TimeEntityRecognizer</a></li><li><a href="Bravey.Language.EN.TimePeriodEntityRecognizer.html">TimePeriodEntityRecognizer</a></li><li><a href="Bravey.Language.IT.DateEntityRecognizer.html">DateEntityRecognizer</a></li><li><a href="Bravey.Language.IT.FreeTextEntityRecognizer.html">FreeTextEntityRecognizer</a></li><li><a href="Bravey.Language.IT.NumberEntityRecognizer.html">NumberEntityRecognizer</a></li><li><a href="Bravey.Language.IT.Stemmer.html">Stemmer</a></li><li><a href="Bravey.Language.IT.TimeEntityRecognizer.html">TimeEntityRecognizer</a></li><li><a href="Bravey.Language.IT.TimePeriodEntityRecognizer.html">TimePeriodEntityRecognizer</a></li><li><a href="Bravey.Language.PT.DateEntityRecognizer.html">DateEntityRecognizer</a></li><li><a href="Bravey.Language.PT.FreeTextEntityRecognizer.html">FreeTextEntityRecognizer</a></li><li><a href="Bravey.Language.PT.NumberEntityRecognizer.html">NumberEntityRecognizer</a></li><li><a href="Bravey.Language.PT.Stemmer.html">Stemmer</a></li><li><a href="Bravey.Language.PT.TimeEntityRecognizer.html">TimeEntityRecognizer</a></li><li><a href="Bravey.Language.PT.TimePeriodEntityRecognizer.html">TimePeriodEntityRecognizer</a></li><li><a href="Bravey.Nlp.Fuzzy.html">Fuzzy</a></li><li><a href="Bravey.Nlp.Sequential.html">Sequential</a></li><li><a href="Bravey.NumberEntityRecognizer.html">NumberEntityRecognizer</a></li><li><a href="Bravey.RegexEntityRecognizer.html">RegexEntityRecognizer</a></li><li><a href="Bravey.SessionManager.InMemorySessionManager.html">InMemorySessionManager</a></li><li><a href="Bravey.StringEntityRecognizer.html">StringEntityRecognizer</a></li><li><a href="Bravey.Text.RegexMap.html">RegexMap</a></li></ul><h3>Namespaces</h3><ul><li><a href="Bravey.html">Bravey</a></li><li><a href="Bravey.Data.html">Data</a></li><li><a href="Bravey.Date.html">Date</a></li><li><a href="Bravey.File.html">File</a></li><li><a href="Bravey.Filter.html">Filter</a></li><li><a href="Bravey.Language.html">Language</a></li><li><a href="Bravey.Language.EN.html">EN</a></li><li><a href="Bravey.Language.IT.html">IT</a></li><li><a href="Bravey.Language.PT.html">PT</a></li><li><a href="Bravey.Nlp.html">Nlp</a></li><li><a href="Bravey.SessionManager.html">SessionManager</a></li><li><a href="Bravey.Text.html">Text</a></li></ul><h3><a href="global.html">Global</a></h3> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.4.3</a> </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>