-
- All Implemented Interfaces:
public final class ChannelClient
-
-
Method Summary
Modifier and Type Method Description final StringgetCid()final StringgetChannelType()final StringgetChannelId()final Call<Channel>create(List<String> memberIds, Map<String, Object> extraData)Creates the id-based channel. final Disposablesubscribe(ChatEventListener<ChatEvent> listener)final DisposablesubscribeFor(String eventTypes, ChatEventListener<ChatEvent> listener)final DisposablesubscribeFor(LifecycleOwner lifecycleOwner, String eventTypes, ChatEventListener<ChatEvent> listener)final DisposablesubscribeFor(Class<out ChatEvent> eventTypes, ChatEventListener<ChatEvent> listener)final DisposablesubscribeFor(LifecycleOwner lifecycleOwner, Class<out ChatEvent> eventTypes, ChatEventListener<ChatEvent> listener)final DisposablesubscribeForSingle(String eventType, ChatEventListener<ChatEvent> listener)final <T extends ChatEvent> DisposablesubscribeForSingle(Class<T> eventType, ChatEventListener<T> listener)final Call<Channel>query(QueryChannelRequest request)final Call<Channel>watch(WatchChannelRequest request)final Call<Channel>watch(Map<String, Object> data)final Call<Channel>watch()final Call<Unit>stopWatching()final Call<Message>getMessage(String messageId)final Call<Message>updateMessage(Message message)final Call<Message>deleteMessage(String messageId, Boolean hard)final Call<Message>deleteMessage(String messageId)final Call<Message>sendMessage(Message message, Boolean isRetrying)Sends the message to the given channel with side effects if there is any plugin added in the client. final Call<Message>sendMessage(Message message)Sends the message to the given channel with side effects if there is any plugin added in the client. final Call<Unit>banUser(String targetId, String reason, Integer timeout)final Call<Unit>unbanUser(String targetId)final Call<Unit>shadowBanUser(String targetId, String reason, Integer timeout)final Call<Unit>removeShadowBan(String targetId)final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual, Date createdAtBefore, Date createdAtBeforeOrEqual)final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual, Date createdAtBefore)final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual)final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter)final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit)final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset)final Call<List<BannedUser>>queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort)final Call<List<BannedUser>>queryBannedUsers(FilterObject filter)final Call<List<BannedUser>>queryBannedUsers()final Call<Unit>markMessageRead(String messageId)final Call<Unit>markRead()final Call<Channel>delete()final Call<Unit>show()final Call<Unit>hide(Boolean clearHistory)Hides the channel. final Call<Channel>truncate(Message systemMessage)Removes all of the messages of the channel but doesn't affect the channel data or members. final Call<Channel>truncate()Removes all of the messages of the channel but doesn't affect the channel data or members. final Call<UploadedFile>sendFile(File file, ProgressCallback callback)Uploads a file for the given channel. final Call<UploadedFile>sendFile(File file)Uploads a file for the given channel. final Call<UploadedImage>sendImage(File file, ProgressCallback callback)Uploads an image for the given channel. final Call<UploadedImage>sendImage(File file)Uploads an image for the given channel. final Call<Unit>deleteFile(String url)Deletes the file represented by url from the given channel. final Call<Unit>deleteImage(String url)Deletes the image represented by url from the given channel. final Call<Reaction>sendReaction(Reaction reaction, Boolean enforceUnique)Sends the reaction. final Call<Message>sendAction(SendActionRequest request)final Call<Message>deleteReaction(String messageId, String reactionType)Deletes the reaction associated with the message with the given message id. final Call<List<Reaction>>getReactions(String messageId, Integer offset, Integer limit)final Call<List<Message>>getReactions(String messageId, String firstReactionId, Integer limit)final Call<Channel>update(Message message, Map<String, Object> extraData)Updates all of the channel data. final Call<Channel>updatePartial(Map<String, Object> set, List<String> unset)Updates specific fields of channel data retaining the custom data fields which were set previously. final Call<Channel>enableSlowMode(Integer cooldownTimeInSeconds)Enables slow mode for the channel. final Call<Channel>disableSlowMode()Disables slow mode for the channel. final Call<Channel>addMembers(List<String> memberIds, Message systemMessage)Adds members to a given channel. final Call<Channel>removeMembers(List<String> memberIds, Message systemMessage)Removes members from a given channel. final Call<Channel>acceptInvite(String message)final Call<Channel>rejectInvite()final Call<Unit>mute(Integer expiration)Mutes a channel for the current user. final Call<Unit>mute()Mutes a channel for the current user. final Call<Unit>unmute()Unmutes a channel for the current user. final Call<Mute>muteUser(String userId, Integer timeout)Mutes a user. final Call<Mute>muteUser(String userId)Mutes a user. final Call<Unit>unmuteUser(String userId)Unmutes a previously muted user. final Call<Mute>muteCurrentUser()final Call<Unit>unmuteCurrentUser()final Call<ChatEvent>keystroke(String parentId)Sends a start typing event EventType.TYPING_START in this channel to the server. final Call<ChatEvent>keystroke()Sends a start typing event EventType.TYPING_START in this channel to the server. final Call<ChatEvent>stopTyping(String parentId)Sends a stop typing event EventType.TYPING_STOP in this channel to the server. final Call<ChatEvent>stopTyping()Sends a stop typing event EventType.TYPING_STOP in this channel to the server. final Call<ChatEvent>sendEvent(String eventType, Map<Object, Object> extraData)Sends an event to all users watching the channel. final Call<List<Member>>queryMembers(Integer offset, Integer limit, FilterObject filter, QuerySorter<Member> sort, List<Member> members)Queries members for this channel. final Call<List<Attachment>>getFileAttachments(Integer offset, Integer limit)final Call<List<Attachment>>getImageAttachments(Integer offset, Integer limit)final Call<List<Message>>getMessagesWithAttachments(Integer offset, Integer limit, List<String> types)Returns a Call with messages that contain at least one desired type attachment but not necessarily all of them will have a specified type. final Call<List<Message>>getPinnedMessages(Integer limit, QuerySorter<Message> sort, PinnedMessagesPagination pagination)Returns a list of messages pinned in the channel. final Call<Message>pinMessage(Message message, Date expirationDate)final Call<Message>pinMessage(Message message, Integer timeout)final Call<Message>unpinMessage(Message message)-
-
Method Detail
-
getChannelType
final String getChannelType()
-
getChannelId
final String getChannelId()
-
create
@CheckResult() final Call<Channel> create(List<String> memberIds, Map<String, Object> extraData)
Creates the id-based channel.
- Parameters:
memberIds- The list of members' ids.extraData- Map of key-value pairs that let you store extra data
-
subscribe
final Disposable subscribe(ChatEventListener<ChatEvent> listener)
-
subscribeFor
final Disposable subscribeFor(String eventTypes, ChatEventListener<ChatEvent> listener)
-
subscribeFor
final Disposable subscribeFor(LifecycleOwner lifecycleOwner, String eventTypes, ChatEventListener<ChatEvent> listener)
-
subscribeFor
final Disposable subscribeFor(Class<out ChatEvent> eventTypes, ChatEventListener<ChatEvent> listener)
-
subscribeFor
final Disposable subscribeFor(LifecycleOwner lifecycleOwner, Class<out ChatEvent> eventTypes, ChatEventListener<ChatEvent> listener)
-
subscribeForSingle
final Disposable subscribeForSingle(String eventType, ChatEventListener<ChatEvent> listener)
-
subscribeForSingle
final <T extends ChatEvent> Disposable subscribeForSingle(Class<T> eventType, ChatEventListener<T> listener)
-
query
@CheckResult() final Call<Channel> query(QueryChannelRequest request)
-
watch
@CheckResult() final Call<Channel> watch(WatchChannelRequest request)
-
watch
@CheckResult() final Call<Channel> watch()
-
stopWatching
@CheckResult() final Call<Unit> stopWatching()
-
getMessage
@CheckResult() final Call<Message> getMessage(String messageId)
-
updateMessage
@CheckResult() final Call<Message> updateMessage(Message message)
-
deleteMessage
@CheckResult()@JvmOverloads() final Call<Message> deleteMessage(String messageId, Boolean hard)
-
deleteMessage
@CheckResult()@JvmOverloads() final Call<Message> deleteMessage(String messageId)
-
sendMessage
@CheckResult()@JvmOverloads() final Call<Message> sendMessage(Message message, Boolean isRetrying)
Sends the message to the given channel with side effects if there is any plugin added in the client.
- Parameters:
message- Message to send.isRetrying- True if this message is being retried.
-
sendMessage
@CheckResult()@JvmOverloads() final Call<Message> sendMessage(Message message)
Sends the message to the given channel with side effects if there is any plugin added in the client.
- Parameters:
message- Message to send.
-
unbanUser
@CheckResult() final Call<Unit> unbanUser(String targetId)
-
shadowBanUser
@CheckResult() final Call<Unit> shadowBanUser(String targetId, String reason, Integer timeout)
-
removeShadowBan
@CheckResult() final Call<Unit> removeShadowBan(String targetId)
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual, Date createdAtBefore, Date createdAtBeforeOrEqual)
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual, Date createdAtBefore)
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter, Date createdAtAfterOrEqual)
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit, Date createdAtAfter)
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset, Integer limit)
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort, Integer offset)
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter, QuerySorter<BannedUsersSort> sort)
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers(FilterObject filter)
-
queryBannedUsers
@CheckResult()@JvmOverloads() final Call<List<BannedUser>> queryBannedUsers()
-
markMessageRead
@CheckResult() final Call<Unit> markMessageRead(String messageId)
-
markRead
@CheckResult() final Call<Unit> markRead()
-
delete
@CheckResult() final Call<Channel> delete()
-
show
@CheckResult() final Call<Unit> show()
-
hide
@CheckResult() final Call<Unit> hide(Boolean clearHistory)
Hides the channel.
- Parameters:
clearHistory- Boolean, if you want to clear the history of this channel or not.
-
truncate
@CheckResult()@JvmOverloads() final Call<Channel> truncate(Message systemMessage)
Removes all of the messages of the channel but doesn't affect the channel data or members.
- Parameters:
systemMessage- The system message object that will be shown in the channel.
-
truncate
@CheckResult()@JvmOverloads() final Call<Channel> truncate()
Removes all of the messages of the channel but doesn't affect the channel data or members.
-
sendFile
@CheckResult()@JvmOverloads() final Call<UploadedFile> sendFile(File file, ProgressCallback callback)
Uploads a file for the given channel. Progress can be accessed via callback.
The Stream CDN imposes the following restrictions on file uploads:
The maximum file size is 20 MB
- Parameters:
file- The file that needs to be uploaded.callback- The callback to track progress.
-
sendFile
@CheckResult()@JvmOverloads() final Call<UploadedFile> sendFile(File file)
Uploads a file for the given channel. Progress can be accessed via callback.
The Stream CDN imposes the following restrictions on file uploads:
The maximum file size is 20 MB
- Parameters:
file- The file that needs to be uploaded.
-
sendImage
@CheckResult()@JvmOverloads() final Call<UploadedImage> sendImage(File file, ProgressCallback callback)
Uploads an image for the given channel. Progress can be accessed via callback.
The Stream CDN imposes the following restrictions on image uploads:
The maximum image size is 20 MB
Supported MIME types are listed in StreamCdnImageMimeTypes.SUPPORTED_IMAGE_MIME_TYPES
- Parameters:
file- The image file that needs to be uploaded.callback- The callback to track progress.
-
sendImage
@CheckResult()@JvmOverloads() final Call<UploadedImage> sendImage(File file)
Uploads an image for the given channel. Progress can be accessed via callback.
The Stream CDN imposes the following restrictions on image uploads:
The maximum image size is 20 MB
Supported MIME types are listed in StreamCdnImageMimeTypes.SUPPORTED_IMAGE_MIME_TYPES
- Parameters:
file- The image file that needs to be uploaded.
-
deleteFile
@CheckResult() final Call<Unit> deleteFile(String url)
Deletes the file represented by url from the given channel.
- Parameters:
url- The URL of the file to be deleted.
-
deleteImage
@CheckResult() final Call<Unit> deleteImage(String url)
Deletes the image represented by url from the given channel.
- Parameters:
url- The URL of the image to be deleted.
-
sendReaction
@CheckResult() final Call<Reaction> sendReaction(Reaction reaction, Boolean enforceUnique)
Sends the reaction. Use enforceUnique parameter to specify whether the reaction should replace other reactions added by the current user.
- Parameters:
reaction- The Reaction to send.enforceUnique- Flag to determine whether the reaction should replace other ones added by the current user.
-
sendAction
@CheckResult() final Call<Message> sendAction(SendActionRequest request)
-
deleteReaction
@CheckResult() final Call<Message> deleteReaction(String messageId, String reactionType)
Deletes the reaction associated with the message with the given message id.
- Parameters:
messageId- The id of the message to which reaction belongs.reactionType- The type of reaction.
-
getReactions
@CheckResult() final Call<List<Reaction>> getReactions(String messageId, Integer offset, Integer limit)
-
getReactions
@CheckResult() final Call<List<Message>> getReactions(String messageId, String firstReactionId, Integer limit)
-
update
@CheckResult() final Call<Channel> update(Message message, Map<String, Object> extraData)
Updates all of the channel data. Any data that is present on the channel and not included in a full update will be deleted.
- Parameters:
message- The message object allowing you to show a system message in the channel.extraData- The updated channel extra data.
-
updatePartial
@CheckResult() final Call<Channel> updatePartial(Map<String, Object> set, List<String> unset)
Updates specific fields of channel data retaining the custom data fields which were set previously.
- Parameters:
set- The key-value data which will be added to the existing channel data object.unset- The list of fields which will be removed from the existing channel data object.
-
enableSlowMode
@CheckResult() final Call<Channel> enableSlowMode(Integer cooldownTimeInSeconds)
Enables slow mode for the channel. When slow mode is enabled, users can only send a message every cooldownTimeInSeconds time interval. The cooldownTimeInSeconds is specified in seconds, and should be between 1-120.
- Parameters:
cooldownTimeInSeconds- The duration of the time interval users have to wait between messages.
-
disableSlowMode
@CheckResult() final Call<Channel> disableSlowMode()
Disables slow mode for the channel.
-
addMembers
@CheckResult() final Call<Channel> addMembers(List<String> memberIds, Message systemMessage)
Adds members to a given channel.
- Parameters:
memberIds- The list of the member ids to be added.systemMessage- The system message object that will be shown in the channel.
-
removeMembers
@CheckResult() final Call<Channel> removeMembers(List<String> memberIds, Message systemMessage)
Removes members from a given channel.
- Parameters:
memberIds- The list of the member ids to be removed.systemMessage- The system message object that will be shown in the channel.
-
acceptInvite
@CheckResult() final Call<Channel> acceptInvite(String message)
-
rejectInvite
@CheckResult() final Call<Channel> rejectInvite()
-
mute
@JvmOverloads()@CheckResult() final Call<Unit> mute(Integer expiration)
Mutes a channel for the current user. Messages added to the channel will not trigger push notifications, and will not change the unread count for the users that muted it. By default, mutes stay in place indefinitely until the user removes it. However, you can optionally set an expiration time. Triggers
notification.channel_mutes_updatedevent.- Parameters:
expiration- The duration of mute in millis.
-
mute
@JvmOverloads()@CheckResult() final Call<Unit> mute()
Mutes a channel for the current user. Messages added to the channel will not trigger push notifications, and will not change the unread count for the users that muted it. By default, mutes stay in place indefinitely until the user removes it. However, you can optionally set an expiration time. Triggers
notification.channel_mutes_updatedevent.
-
unmute
@CheckResult() final Call<Unit> unmute()
Unmutes a channel for the current user. Triggers
notification.channel_mutes_updatedevent.
-
muteUser
@JvmOverloads()@CheckResult() final Call<Mute> muteUser(String userId, Integer timeout)
Mutes a user. Messages from muted users will not trigger push notifications. By default, mutes stay in place indefinitely until the user removes it. However, you can optionally set a mute timeout. Triggers
notification.mutes_updatedevent.- Parameters:
userId- The user id to mute.timeout- The timeout in minutes until the mute is expired.
-
muteUser
@JvmOverloads()@CheckResult() final Call<Mute> muteUser(String userId)
Mutes a user. Messages from muted users will not trigger push notifications. By default, mutes stay in place indefinitely until the user removes it. However, you can optionally set a mute timeout. Triggers
notification.mutes_updatedevent.- Parameters:
userId- The user id to mute.
-
unmuteUser
@CheckResult() final Call<Unit> unmuteUser(String userId)
Unmutes a previously muted user. Triggers
notification.mutes_updatedevent.- Parameters:
userId- The user id to unmute.
-
muteCurrentUser
@CheckResult() final Call<Mute> muteCurrentUser()
-
unmuteCurrentUser
@CheckResult() final Call<Unit> unmuteCurrentUser()
-
keystroke
@CheckResult()@JvmOverloads() final Call<ChatEvent> keystroke(String parentId)
Sends a start typing event EventType.TYPING_START in this channel to the server.
- Parameters:
parentId- Set this field tomessage.idto indicate that typing event is happening in a thread.
-
keystroke
@CheckResult()@JvmOverloads() final Call<ChatEvent> keystroke()
Sends a start typing event EventType.TYPING_START in this channel to the server.
-
stopTyping
@CheckResult()@JvmOverloads() final Call<ChatEvent> stopTyping(String parentId)
Sends a stop typing event EventType.TYPING_STOP in this channel to the server.
- Parameters:
parentId- Set this field tomessage.idto indicate that typing event is happening in a thread.
-
stopTyping
@CheckResult()@JvmOverloads() final Call<ChatEvent> stopTyping()
Sends a stop typing event EventType.TYPING_STOP in this channel to the server.
-
sendEvent
@CheckResult() final Call<ChatEvent> sendEvent(String eventType, Map<Object, Object> extraData)
Sends an event to all users watching the channel.
- Parameters:
eventType- The event name.extraData- The event payload.
-
queryMembers
@CheckResult() final Call<List<Member>> queryMembers(Integer offset, Integer limit, FilterObject filter, QuerySorter<Member> sort, List<Member> members)
Queries members for this channel.
- Parameters:
offset- Offset limit.limit- Number of members to fetch.filter- FilterObject to filter members of certain type.sort- Sort the list of members.members- List of members to search in distinct channels.
-
getFileAttachments
@CheckResult() final Call<List<Attachment>> getFileAttachments(Integer offset, Integer limit)
-
getImageAttachments
@CheckResult() final Call<List<Attachment>> getImageAttachments(Integer offset, Integer limit)
-
getMessagesWithAttachments
@CheckResult() final Call<List<Message>> getMessagesWithAttachments(Integer offset, Integer limit, List<String> types)
Returns a Call with messages that contain at least one desired type attachment but not necessarily all of them will have a specified type.
- Parameters:
offset- The messages offset.limit- Max limit messages to be fetched.types- Desired attachment's types list.
-
getPinnedMessages
@CheckResult() final Call<List<Message>> getPinnedMessages(Integer limit, QuerySorter<Message> sort, PinnedMessagesPagination pagination)
Returns a list of messages pinned in the channel. You can sort the list by specifying sort parameter. Keep in mind that for now we only support sorting by Message.pinnedAt. The list can be paginated in a few different ways using limit and pagination.
- Parameters:
limit- Max limit of messages to be fetched.sort- Parameter by which we sort the messages.pagination- Provides different options for pagination.
-
pinMessage
@CheckResult() final Call<Message> pinMessage(Message message, Date expirationDate)
-
pinMessage
@CheckResult() final Call<Message> pinMessage(Message message, Integer timeout)
-
unpinMessage
@CheckResult() final Call<Message> unpinMessage(Message message)
-
-
-
-