public final class Channel
extends java.lang.Object
implements android.os.Parcelable
Channels.createChannel(java.lang.String, com.twilio.chat.Channel.ChannelType, com.twilio.chat.CallbackListener<com.twilio.chat.Channel>)
, Channels.getChannel(java.lang.String, com.twilio.chat.CallbackListener<com.twilio.chat.Channel>)
or
get it from collections returned by Channels.getPublicChannels(com.twilio.chat.CallbackListener<com.twilio.chat.Paginator<com.twilio.chat.ChannelDescriptor>>)
and
Channels.getUserChannels(com.twilio.chat.CallbackListener<com.twilio.chat.Paginator<com.twilio.chat.Channel>>)
.
Channel is a relatively heavy-weight object. It receives state updates from the back-end
in real time.Modifier and Type | Class and Description |
---|---|
static class |
Channel.ChannelStatus
This enum represents the various states of the member with respect to
this channel.
|
static class |
Channel.ChannelType
Enumeration indicating the channel's visibility.
|
static class |
Channel.SynchronizationStatus
Enumeration indicating synchronization status for channel.
|
Modifier and Type | Field and Description |
---|---|
static android.os.Parcelable.Creator<Channel> |
CREATOR |
Modifier and Type | Method and Description |
---|---|
void |
addListener(ChannelListener listener)
Add a new
ChannelListener for this Channel. |
void |
declineInvitation(StatusListener listener)
Declines an invite on this channel.
|
int |
describeContents() |
void |
destroy(StatusListener listener)
Destroys the current channel.
|
void |
dispose() |
org.json.JSONObject |
getAttributes()
Custom attributes associated with the Channel.
|
java.lang.String |
getDateCreated()
Get creation date of the channel as an ISO 8601 string.
|
java.util.Date |
getDateCreatedAsDate()
Get creation date of the channel.
|
java.lang.String |
getDateUpdated()
Get update date of the channel as an ISO 8601 string.
|
java.util.Date |
getDateUpdatedAsDate()
Get update date of the channel.
|
java.lang.String |
getFriendlyName()
Obtain friendly name of the channel.
|
Members |
getMembers()
Get members object that allows access to members roster in the channel.
|
void |
getMembersCount(CallbackListener<java.lang.Integer> listener)
Get total number of members in the channel roster.
|
Messages |
getMessages()
Get messages object that allows access to messages in the channel.
|
void |
getMessagesCount(CallbackListener<java.lang.Integer> listener)
Get total number of messages in the channel.
|
java.lang.String |
getSid()
Obtain unique identifier for this channel.
|
Channel.ChannelStatus |
getStatus()
Returns the current user's participation status on this channel.
|
Channel.SynchronizationStatus |
getSynchronizationStatus()
Get the current synchronization status for channel.
|
Channel.ChannelType |
getType()
Obtain channel type.
|
void |
getUnconsumedMessagesCount(CallbackListener<java.lang.Integer> listener)
Get number of unconsumed messages in the channel.
|
java.lang.String |
getUniqueName()
Obtain unique name of the channel.
|
void |
join(StatusListener listener)
Joins the current user to the channel.
|
void |
leave(StatusListener listener)
Leaves the current channel.
|
void |
removeAllListeners()
Remove all ChannelListeners for this Channel.
|
void |
removeListener(ChannelListener listener)
Remove ChannelListener for this Channel.
|
void |
setAttributes(org.json.JSONObject updatedAttributes,
StatusListener listener)
Updates the attribute data for this channel.
|
void |
setFriendlyName(java.lang.String friendlyName,
StatusListener listener)
Updates the friendly name for this channel.
|
void |
setUniqueName(java.lang.String uniqueName,
StatusListener listener)
Updates the unique name for this channel.
|
void |
synchronize(CallbackListener<Channel> listener)
Synchronize the channel.
|
void |
typing()
Indicate when Member is typing on this channel.
|
void |
writeToParcel(android.os.Parcel dest,
int flags) |
public static final android.os.Parcelable.Creator<Channel> CREATOR
public java.lang.String getSid()
Channels.getChannel(java.lang.String, com.twilio.chat.CallbackListener<com.twilio.chat.Channel>)
. The channel sid is persistent.public java.lang.String getFriendlyName()
public void setFriendlyName(java.lang.String friendlyName, StatusListener listener)
friendlyName
- New friendly name.listener
- Listener that will receive callback with the result.public Channel.ChannelType getType()
Channel.ChannelType
for more information.public java.lang.String getUniqueName()
public void setUniqueName(java.lang.String uniqueName, StatusListener listener)
uniqueName
- New unique name for this channel.listener
- Listener that will receive callback with the result.public org.json.JSONObject getAttributes() throws org.json.JSONException
org.json.JSONException
- Exception is thrown if attributes could not be parsed.public void setAttributes(org.json.JSONObject updatedAttributes, StatusListener listener)
updatedAttributes
- attributes to change.listener
- Listener that will receive callback with the result.public Messages getMessages()
synchronize(com.twilio.chat.CallbackListener<com.twilio.chat.Channel>)
the channel before you call this method,
unless you just join(com.twilio.chat.StatusListener)
ed the channel, in which case it synchronizes automatically.public Channel.ChannelStatus getStatus()
public void addListener(ChannelListener listener)
ChannelListener
for this Channel. Channel listeners receive real time
updates about changes in the channel state, messages and members.
This listener will be called on the originating thread if it has a Looper, otherwise
on the main UI thread.listener
- A channel listener.public void removeListener(ChannelListener listener)
listener
- Listener to remove.public void removeAllListeners()
public Members getMembers()
synchronize(com.twilio.chat.CallbackListener<com.twilio.chat.Channel>)
the channel before you call this method,
unless you just join(com.twilio.chat.StatusListener)
ed the channel, in which case it synchronizes automatically.public void join(StatusListener listener)
listener
- Listener that will receive callback with the result.public void leave(StatusListener listener)
listener
- Listener that will receive callback with the result.public void destroy(StatusListener listener)
listener
- Listener that will receive callback with the result.public void declineInvitation(StatusListener listener)
listener
- Listener that will receive callback with the result.public void typing()
ChannelListener.onTypingStarted(com.twilio.chat.Member)
and
ChannelListener.onTypingEnded(com.twilio.chat.Member)
callbacks.public Channel.SynchronizationStatus getSynchronizationStatus()
public void synchronize(CallbackListener<Channel> listener)
listener
- Callback listener.public java.lang.String getDateCreated()
public java.util.Date getDateCreatedAsDate()
public java.lang.String getDateUpdated()
public java.util.Date getDateUpdatedAsDate()
public void getMessagesCount(CallbackListener<java.lang.Integer> listener)
listener
- Listener to receive results of the query.public void getUnconsumedMessagesCount(CallbackListener<java.lang.Integer> listener)
listener
- Listener to receive results of the query.public void getMembersCount(CallbackListener<java.lang.Integer> listener)
listener
- Listener to receive results of the query.public int describeContents()
describeContents
in interface android.os.Parcelable
public void writeToParcel(android.os.Parcel dest, int flags)
writeToParcel
in interface android.os.Parcelable
public void dispose()