Class: Channel

Channel

A Channel represents a remote channel of communication between multiple IP Messaging Clients.

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 'unknown' | 'known' | 'invited' | 'joined' | 'failed' Whether the Channel is 'known' to local Client, Client is 'invited' to or is 'joined' to this Channel.
type 'public' | 'private' The Channel's type as a String: ['private', 'public']
uniqueName String The Channel's unique name (tag).
Fires:
  • Channel#event:memberJoined
  • Channel#event:memberLeft
  • Channel#event:memberUpdated
  • Channel#event:messageAdded
  • Channel#event:messageRemoved
  • Channel#event:messageUpdated
  • Channel#event:typingEnded
  • Channel#event:typingStarted
  • Channel#event:updated

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.<(void|Error|SessionError)>

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.<(void|Error|SessionError)>

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.<number>

getMessages( [pageSize] [, anchor] [, direction])

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.
direction String <optional>
backwards Query direction. By default it query backwards from newer to older. 'forward' will query in opposite direction.
Returns:
page of messages
Type
Promise.<Paginator.<Message>>

getMessagesCount()

Get total message count in a channel
Returns:
Type
Promise.<number>

getUnconsumedMessagesCount()

Get unconsumed messages count
Returns:
Type
Promise.<number>

getUserDescriptors()

Gets User Descriptors for this channel
Returns:
Type
Promise.<Paginator.<UserDescriptor>>

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.<(void|Error|SessionError)>

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 String identity of member to remove.
Returns:
Type
Promise.<(void|Error|SessionError)>

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.<Channel>

setNoMessagesConsumed()

Set all messages in the channel unread
Returns:
Type
Promise.<Channel>

typing()

Send a notification to the server indicating that this Client is currently typing in this Channel.
Returns:
Type
Promise.<(void|SessionError)>

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|Error|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.<(void|Error|SessionError)>

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)>