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. |
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). |
Fires:
Members
-
<static, readonly> status :String
-
The status of the Channel, relative to the Client.
Type:
- String
Properties:
Name Type Default Description KNOWN
String known 'known' | This Client knows about the Channel, but the User is neither joined nor invited to it. INVITED
String invited 'invited' | This Client's User is invited to the Channel. JOINED
String joined 'joined' | This Client's User is joined to the Channel. FAILED
String failed 'failed' | This Channel is malformed, or has failed to load. -
<static, readonly> type :String
-
The type of Channel (Public or private).
Type:
- String
Properties:
Name Type Default Description PUBLIC
String public 'public' | This channel is Public. PRIVATE
String private 'private' | This channel is Private.
Methods
-
add(identity)
-
Add a participant to the Channel by its Identity.
Parameters:
Name Type Description identity
String Identity of the Client to add. Returns:
- Type
- Promise
-
advanceLastConsumedMessageIndex(index)
-
Advance last consumed Channel's Message index to current consumption horizon. Last consumed Message index is updated only if new index value is higher than previous.
Parameters:
Name Type Description index
Number Message index to advance to as last read. Returns:
- Type
- Promise
-
decline()
-
Decline an invitation to the Channel.
Returns:
- Type
- Promise.<(Channel|SessionError)>
-
delete()
-
Delete the Channel.
Returns:
- Type
- Promise.<(Channel|SessionError)>
-
getAttributes()
-
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.
Returns:
- Type
- Promise.<Object>
-
getMembers()
-
Get a list of all Members joined to this Channel.
Returns:
- Type
- Promise.<Array.<Member>>
-
getMembersCount()
-
Get channel members count
Returns:
- Type
- Promise.<integer>
-
getMessages( [pageSize] [, anchor])
-
Returns messages from channel using paginator interface
Parameters:
Name Type Argument Default Description pageSize
Number <optional>
30 Number of messages to return in single chunk. anchor
Number <optional>
Index of newest Message to fetch. From the end by default. Returns:
page of messages -
getMessagesCount()
-
Get total message count in a channel
Returns:
- Type
- Promise.<integer>
-
getUnconsumedMessagesCount()
-
Get unconsumed messages count
Returns:
- Type
- Promise.<integer>
-
invite(identity)
-
Invite a user to the Channel by their Identity.
Parameters:
Name Type Description identity
String Identity of the user to invite. Returns:
- Type
- Promise
-
join()
-
Join the Channel.
Returns:
- Type
- Promise.<(Channel|SessionError)>
-
leave()
-
Leave the Channel.
Returns:
- Type
- Promise.<(Channel|SessionError)>
-
removeMember(member)
-
Remove a Member from the Channel.
Parameters:
Name Type Description member
Member | String The Member (Or identity) to remove. Returns:
- Type
- Promise.<Member>
-
sendMessage(messageBody, messageAttributes)
-
Send a Message on the Channel.
Parameters:
Name Type Description messageBody
String The message body. messageAttributes
Object attributes for the message Returns:
A Promise for the message ID- Type
- Promise.<String>
-
setAllMessagesConsumed()
-
Set last consumed Channel's Message index to last known Message's index in this Channel.
Returns:
- Type
- Promise
-
setNoMessagesConsumed()
-
Set all messages in the channel unread
-
typing()
-
Send a notification to the server indicating that this Client is currently typing in this Channel.
Returns:
- Type
- Promise
-
updateAttributes(attributes)
-
Update the Channel's attributes.
Parameters:
Name Type Description attributes
Object The new attributes object. Returns:
A Promise for the Channel- Type
- Promise.<(Channel|SessionError)>
-
updateFriendlyName(name)
-
Update the Channel's friendlyName.
Parameters:
Name Type Description name
String The new Channel friendlyName. Returns:
A Promise for the Channel- Type
- Promise.<(Channel|SessionError)>
-
updateLastConsumedMessageIndex(index)
-
Set last consumed Channel's Message index to current consumption horizon.
Parameters:
Name Type Description index
Number | null Message index to set as last read. Null if no messages have been read Returns:
- Type
- Promise
-
updateUniqueName(uniqueName)
-
Update the Channel's unique name (tag).
Parameters:
Name Type Description uniqueName
String The new Channel uniqueName. Returns:
A Promise for the Channel- Type
- Promise.<(Channel|SessionError)>
Events
-
memberInfoUpdated
-
Fired when a Member's UserInfo fields has been updated.
Parameters:
Name Type Description member
Member -
memberJoined
-
Fired when a Member has joined the Channel.
Parameters:
Name Type Description member
Member -
memberLeft
-
Fired when a Member has left the Channel.
Parameters:
Name Type Description member
Member -
memberUpdated
-
Fired when a Member's fields has been updated.
Parameters:
Name Type Description member
Member -
messageAdded
-
Fired when a new Message has been added to the Channel on the server.
Parameters:
Name Type Description message
Message -
messageRemoved
-
Fired when Message is removed from Channel's message list.
Parameters:
Name Type Description message
Message -
messageUpdated
-
Fired when an existing Message's fields are updated with new values.
Parameters:
Name Type Description message
Message -
typingEnded
-
Fired when a member has stopped typing.
Parameters:
Name Type Description member
Member -
typingStarted
-
Fired when a member has begun typing.
Parameters:
Name Type Description member
Member -
updated
-
Fired when the Channel's fields have been updated.
Parameters:
Name Type Description channel
Channel