Users module.
- Source:
Members
(inner, constant) userHandler :Object
This object is used to handle every user object. Each user has an unique id, a DetectorHandler object to manage the
detectors they need, an expiration date and a fixed lifespan.
Type:
- Object
- Source:
Methods
(inner) addUser(uniqueID) → {number}
Adds a new user to the system. Each user will hold their own emotion detector. Users have a limited lifespan,
especified in the
expires
attribute. A setInterval
function is used to remove every expired
user. Users can increase their lifespan by doing actions, which will move their expire date active
miliseconds
into the future.
Parameters:
Name | Type | Description |
---|---|---|
uniqueID |
number | Unique id value generated with uniqid npm module. |
- Source:
Returns:
Unique user id.
- Type
- number
(inner) enableUserExpirationInterval()
Interval function which scans the users array with a certain frecuency looking for expired users.
If the users array is empty, this interval stops, and it's reenabled when a new user is added.
- Source:
(inner) expirationTime()
Expiration function called at a specified interval which filters out expired users.
- Source:
(inner) getDetectorLength() → {number}
- Source:
Returns:
Total number of detectors.
- Type
- number
(inner) getUser(id) → {Object|undefined}
Retrieve the user object
Parameters:
Name | Type | Description |
---|---|---|
id |
number | Unique id used when the user was created. |
- Source:
Returns:
User object, or undefined if the user doesn't exist.
- Type
- Object | undefined
(inner) refreshUserSession(user)
Refresh an user's expiration time. This function must be called everytime an user performs an action.
Parameters:
Name | Type | Description |
---|---|---|
user |
Object | number | The user object or its numeric id. |
- Source:
(inner) setupUserDetector(userId, preferences) → {number}
Sets up an user's detectors according to a set of parameters especified in
preferences
(see /setup). This function just called the
setupDetectors
function in
DetectorHandler
and returned the number
of detectors affected by the filtering.
Parameters:
Name | Type | Description |
---|---|---|
userId |
string | User unique id. |
preferences |
Object | Detectors setup information. |
- Source:
Returns:
Number of filtered (removed) detectors.
- Type
- number
(inner) userExists(id) → {boolean}
Checks if user exists.
Parameters:
Name | Type | Description |
---|---|---|
id |
number | Unique id used when the user was created. |
- Source:
Returns:
Does the user exist?
- Type
- boolean