Constructor
new Channel()
Properties:
Name | Type | Description |
---|---|---|
attributes |
Object | The Channel's custom attributes. |
createdBy |
String | The identity of the User that created this Channel. |
dateCreated |
Date | The Date this Channel was created. |
dateUpdated |
Date | The Date this Channel was last updated. |
friendlyName |
String | The Channel's name. |
isPrivate |
Boolean | Whether the channel is private (as opposed to public). |
lastConsumedMessageIndex |
Number | Index of the last Message the User has consumed in this Channel. |
members |
Map.<Sid, Member> | A map of Members in the Channel. |
messages |
Array.<Message> | An sorted array of Messages in the Channel. |
sid |
String | The Channel's unique system identifier. |
status |
Enumeration | Whether the Channel is 'known' to local Client, Client is 'invited' to or is 'joined' to this Channel. |
type |
Enumeration | The Channel's type as a String: ['private', 'public'] |
uniqueName |
String | The Channel's unique name (tag). |
- Source:
Fires:
Members
(static, readonly) status :String
The status of the Channel, relative to the Client.
Type:
- String
Properties:
Name | Type | Description |
---|---|---|
KNOWN |
String | 'known' | This Client knows about the Channel, but the User is neither joined nor invited to it. |
INVITED |
String | 'invited' | This Client's User is invited to the Channel. |
JOINED |
String | 'joined' | This Client's User is joined to the Channel. |
FAILED |
String | 'failed' | This Channel is malformed, or has failed to load. |
- Source:
(static, readonly) type :String
The type of Channel (Public or private).
Type:
- String
Properties:
Name | Type | Description |
---|---|---|
PUBLIC |
String | 'public' | This channel is Public. |
PRIVATE |
String | 'private' | This channel is Private. |
- Source:
Methods
add(identity) → {Promise}
Add a Client to the Channel by its Identity.
Parameters:
Name | Type | Description |
---|---|---|
identity |
String | Identity of the Client to add. |
- Source:
Returns:
- Type
- Promise
decline() → {Promise.<Channel>}
Decline an invitation to the Channel.
- Source:
Returns:
- Type
- Promise.<Channel>
delete() → {Promise.<Channel>}
Delete the Channel.
- Source:
Returns:
- Type
- Promise.<Channel>
getAttributes() → {Promise.<Object>}
Get the custom attributes of this channel.
NOTE: Attributes will be empty in public channels until this is called.
However, private channels will already have this due to back-end limitation.
- Source:
Returns:
- Type
- Promise.<Object>
getMembers() → {Promise.<Array.<Member>>}
Get a list of all Members joined to this Channel.
- Source:
Returns:
- Type
- Promise.<Array.<Member>>
getMessages(countopt, anchoropt) → {Promise.<Array.<Message>>}
Get a sorted list of Messages.
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
count |
Number |
<optional> |
Amount of Messages to fetch | |
anchor |
String |
<optional> |
'end' | Newest Message to fetch |
- Source:
Returns:
- Type
- Promise.<Array.<Message>>
invite(identity) → {Promise}
Invite a user to the Channel by their Identity.
Parameters:
Name | Type | Description |
---|---|---|
identity |
String | Identity of the user to invite. |
- Source:
Returns:
- Type
- Promise
join() → {Promise.<Channel>}
Join the Channel.
- Source:
Returns:
- Type
- Promise.<Channel>
leave() → {Promise.<Channel>}
Leave the Channel.
- Source:
Returns:
- Type
- Promise.<Channel>
removeMember(member) → {Promise.<Member>}
Remove a Member from the Channel.
Parameters:
Name | Type | Description |
---|---|---|
member |
Member | String | The Member (Or identity) to remove. |
- Source:
Returns:
- Type
- Promise.<Member>
sendMessage(messageBody) → {Promise.<String>}
Send a Message on the Channel.
Parameters:
Name | Type | Description |
---|---|---|
messageBody |
String | The message body. |
- Source:
Returns:
A Promise for the message ID
- Type
- Promise.<String>
typing() → {Promise}
Send a notification to the server indicating that this Client is currently typing in this Channel.
- Source:
Returns:
- Type
- Promise
updateAttributes(attributes) → {Promise.<Channel>}
Update the Channel's attributes.
Parameters:
Name | Type | Description |
---|---|---|
attributes |
Object | The new attributes object. |
- Source:
Returns:
A Promise for the Channel
- Type
- Promise.<Channel>
updateFriendlyName(name) → {Promise.<Channel>}
Update the Channel's friendlyName.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The new Channel friendlyName. |
- Source:
Returns:
A Promise for the Channel
- Type
- Promise.<Channel>
updateLastConsumedMessageIndex(index) → {Promise}
Set last consumed Channel's Message index to current consumption horizon.
Parameters:
Name | Type | Description |
---|---|---|
index |
Number | Message index to set as last read. |
- Source:
Returns:
- Type
- Promise
updateUniqueName(uniqueName) → {Promise.<Channel>}
Update the Channel's unique name (tag).
Parameters:
Name | Type | Description |
---|---|---|
uniqueName |
String | The new Channel uniqueName. |
- Source:
Returns:
A Promise for the Channel
- Type
- Promise.<Channel>
Events
memberJoined
Fired when a Member has joined the Channel.
Parameters:
Name | Type | Description |
---|---|---|
member |
Member |
- Source:
memberLeft
Fired when a Member has left the Channel.
Parameters:
Name | Type | Description |
---|---|---|
member |
Member |
- Source:
memberUpdated
Fired when a Member's fields has been updated.
Parameters:
Name | Type | Description |
---|---|---|
member |
Member |
- Source:
messageAdded
Fired when a new Message has been added to the Channel on the server.
Parameters:
Name | Type | Description |
---|---|---|
message |
Message |
- Source:
messageRemoved
Fired when Message is removed from Channel's message list.
Parameters:
Name | Type | Description |
---|---|---|
message |
Message |
- Source:
messageUpdated
Fired when an existing Message's fields are updated with new values.
Parameters:
Name | Type | Description |
---|---|---|
message |
Message |
- Source:
typingEnded
Fired when a member has begun typing.
Type:
- Source:
typingStarted
Fired when a member has stopped typing.
Type:
- Source:
updated
Fired when the Channel's fields have been updated.
Parameters:
Name | Type | Description |
---|---|---|
channel |
Channel |
- Source: