Class User
Represents an individual user connected to the now server. Exposed as the context in which group.now functions are called, as well as the context in which the callback to nowjs.getClient is executed. Each user has the User#now and User#user namespaces.
- Defined in: user.js
Constructor Attributes | Constructor Name and Description |
---|---|
User()
|
Field Attributes | Field Name and Description |
---|---|
The user's Socket.IO socket.
|
Method Summary
Method Attributes | Method Name and Description |
---|---|
getGroups(callback)
Used to retrieve a list of the group names
corresponding to all groups the user is in.
|
Field Detail
{Socket}
socket
The user's Socket.IO socket.
Method Detail
-
getGroups(callback)Used to retrieve a list of the group names corresponding to all groups the user is in.
everyone.now.broadcast = function (message) { var name = this.now.name; this.getGroups(function (groups) { for (var i = groups.length; i--;) { if (groups[i] !== 'everyone') { nowjs.getGroup(groups[i]).now.receive(name, message); } } });
- Parameters:
- {Function} callback
- Called with an Array of Strings corresponding to the various group names.