-
public final class ChatClientExtensions
-
-
Field Summary
Fields Modifier and Type Field Description private final static StateRegistrystateprivate final static GlobalStateglobalStateprivate final static Flow<GlobalState>globalStateFlow
-
Method Summary
Modifier and Type Method Description final StateRegistrygetState()final GlobalStategetGlobalState()final Flow<GlobalState>getGlobalStateFlow()final static StateFlow<QueryChannelsState>queryChannelsAsState(ChatClient $self, QueryChannelsRequest request, ChatEventHandlerFactory chatEventHandlerFactory, CoroutineScope coroutineScope)Performs ChatClient.queryChannels under the hood and returns QueryChannelsState associated with the query. final static StateFlow<QueryChannelsState>queryChannelsAsState(ChatClient $self, QueryChannelsRequest request, ChatEventHandlerFactory chatEventHandlerFactory)Performs ChatClient.queryChannels under the hood and returns QueryChannelsState associated with the query. final static StateFlow<QueryChannelsState>queryChannelsAsState(ChatClient $self, QueryChannelsRequest request)Performs ChatClient.queryChannels under the hood and returns QueryChannelsState associated with the query. final static StateFlow<QueryChannelsState>initGroupedQueryChannelsAsState(ChatClient $self, QueryChannelsIdentifier.Grouped identifier, ChatEventHandlerFactory chatEventHandlerFactory, CoroutineScope coroutineScope)Creates a QueryChannelsState for the given grouped identifier without triggering a remote queryChannels API call. final static StateFlow<QueryChannelsState>initGroupedQueryChannelsAsState(ChatClient $self, QueryChannelsIdentifier.Grouped identifier, ChatEventHandlerFactory chatEventHandlerFactory)Creates a QueryChannelsState for the given grouped identifier without triggering a remote queryChannels API call. final static StateFlow<QueryChannelsState>initGroupedQueryChannelsAsState(ChatClient $self, QueryChannelsIdentifier.Grouped identifier)Creates a QueryChannelsState for the given grouped identifier without triggering a remote queryChannels API call. final static StateFlow<ChannelState>watchChannelAsState(ChatClient $self, String cid, Integer messageLimit, CoroutineScope coroutineScope)Performs ChatClient.queryChannel with watch = true under the hood and returns ChannelState associated with the query. final static StateFlow<ChannelState>watchChannelAsState(ChatClient $self, String cid, Integer messageLimit)Performs ChatClient.queryChannel with watch = true under the hood and returns ChannelState associated with the query. final static StateFlow<QueryThreadsState>queryThreadsAsState(ChatClient $self, QueryThreadsRequest request, CoroutineScope coroutineScope)Performs ChatClient.queryThreadsResult under the hood and returns QueryThreadsState. final static ThreadStategetRepliesAsState(ChatClient $self, String messageId, Integer messageLimit, Boolean olderToNewer, CoroutineScope coroutineScope)Same class of ChatClient. final static ThreadStategetRepliesAsState(ChatClient $self, String messageId, Integer messageLimit, Boolean olderToNewer)Same class of ChatClient. final static ThreadStateawaitRepliesAsState(ChatClient $self, String messageId, Integer messageLimit, Boolean olderToNewer)Returns thread replies in the form of ThreadState, however, unlike getRepliesAsState it will return it only after the API call made to get replies has ended. final static Call<Unit>setMessageForReply(ChatClient $self, String cid, Message message)Set the reply state for the channel. final static Call<Unit>downloadAttachment(ChatClient $self, Context context, Attachment attachment, Function1<Attachment, Uri> generateDownloadUri, Function1<DownloadManager.Request, Unit> interceptRequest)Downloads the selected attachment to the "Download" folder in the public external storage directory. final static Call<Channel>loadOlderMessages(ChatClient $self, String cid, Integer messageLimit)Loads older messages for the channel. final static Call<Channel>loadNewerMessages(ChatClient $self, String channelCid, String baseMessageId, Integer messageLimit)final static Call<Channel>loadMessagesAroundId(ChatClient $self, String cid, String messageId)Loads messages around the given message id. final static Call<Boolean>cancelEphemeralMessage(ChatClient $self, Message message)Cancels the message of "ephemeral" type. final static Call<Message>getMessageUsingCache(ChatClient $self, String messageId)Attempts to fetch the message from offline cache before making an API call. final static Call<Message>loadMessageById(ChatClient $self, String cid, String messageId)Loads message for a given message id and channel id. final static Call<Channel>loadNewestMessages(ChatClient $self, String cid, Integer messageLimit, Boolean userPresence)Loads the newest messages of a channel. -
-
Method Detail
-
getState
final StateRegistry getState()
-
getGlobalState
final GlobalState getGlobalState()
-
getGlobalStateFlow
final Flow<GlobalState> getGlobalStateFlow()
-
queryChannelsAsState
final static StateFlow<QueryChannelsState> queryChannelsAsState(ChatClient $self, QueryChannelsRequest request, ChatEventHandlerFactory chatEventHandlerFactory, CoroutineScope coroutineScope)
Performs ChatClient.queryChannels under the hood and returns QueryChannelsState associated with the query. The QueryChannelsState cannot be created before connecting the user therefore, the method returns a StateFlow that emits a null when the user has not been connected yet and the new value every time the user changes.
You can pass option chatEventHandlerFactory parameter which will be associated with this query channels request.
- Parameters:
request- The request's parameters combined into QueryChannelsRequest class.chatEventHandlerFactory- The instance of ChatEventHandlerFactory that will be used to create ChatEventHandler.coroutineScope- The CoroutineScope used for executing the request.
-
queryChannelsAsState
final static StateFlow<QueryChannelsState> queryChannelsAsState(ChatClient $self, QueryChannelsRequest request, ChatEventHandlerFactory chatEventHandlerFactory)
Performs ChatClient.queryChannels under the hood and returns QueryChannelsState associated with the query. The QueryChannelsState cannot be created before connecting the user therefore, the method returns a StateFlow that emits a null when the user has not been connected yet and the new value every time the user changes.
You can pass option chatEventHandlerFactory parameter which will be associated with this query channels request.
- Parameters:
request- The request's parameters combined into QueryChannelsRequest class.chatEventHandlerFactory- The instance of ChatEventHandlerFactory that will be used to create ChatEventHandler.
-
queryChannelsAsState
final static StateFlow<QueryChannelsState> queryChannelsAsState(ChatClient $self, QueryChannelsRequest request)
Performs ChatClient.queryChannels under the hood and returns QueryChannelsState associated with the query. The QueryChannelsState cannot be created before connecting the user therefore, the method returns a StateFlow that emits a null when the user has not been connected yet and the new value every time the user changes.
You can pass option chatEventHandlerFactory parameter which will be associated with this query channels request.
- Parameters:
request- The request's parameters combined into QueryChannelsRequest class.
-
initGroupedQueryChannelsAsState
final static StateFlow<QueryChannelsState> initGroupedQueryChannelsAsState(ChatClient $self, QueryChannelsIdentifier.Grouped identifier, ChatEventHandlerFactory chatEventHandlerFactory, CoroutineScope coroutineScope)
Creates a QueryChannelsState for the given grouped identifier without triggering a remote queryChannels API call. Channels cached under the identifier's DB key are loaded optimistically so the UI can render immediately while the next
queryGroupedChannelsresponse populates the state via the listener.Only QueryChannelsIdentifier.Grouped is accepted — the standard offset-paginated path is served by queryChannelsAsState instead.
- Parameters:
identifier- The grouped query's identifier whose state should be initialized.chatEventHandlerFactory- The factory used to create the ChatEventHandler that routes events into this grouped list.coroutineScope- The CoroutineScope used for executing the request.
-
initGroupedQueryChannelsAsState
final static StateFlow<QueryChannelsState> initGroupedQueryChannelsAsState(ChatClient $self, QueryChannelsIdentifier.Grouped identifier, ChatEventHandlerFactory chatEventHandlerFactory)
Creates a QueryChannelsState for the given grouped identifier without triggering a remote queryChannels API call. Channels cached under the identifier's DB key are loaded optimistically so the UI can render immediately while the next
queryGroupedChannelsresponse populates the state via the listener.Only QueryChannelsIdentifier.Grouped is accepted — the standard offset-paginated path is served by queryChannelsAsState instead.
- Parameters:
identifier- The grouped query's identifier whose state should be initialized.chatEventHandlerFactory- The factory used to create the ChatEventHandler that routes events into this grouped list.
-
initGroupedQueryChannelsAsState
final static StateFlow<QueryChannelsState> initGroupedQueryChannelsAsState(ChatClient $self, QueryChannelsIdentifier.Grouped identifier)
Creates a QueryChannelsState for the given grouped identifier without triggering a remote queryChannels API call. Channels cached under the identifier's DB key are loaded optimistically so the UI can render immediately while the next
queryGroupedChannelsresponse populates the state via the listener.Only QueryChannelsIdentifier.Grouped is accepted — the standard offset-paginated path is served by queryChannelsAsState instead.
- Parameters:
identifier- The grouped query's identifier whose state should be initialized.
-
watchChannelAsState
final static StateFlow<ChannelState> watchChannelAsState(ChatClient $self, String cid, Integer messageLimit, CoroutineScope coroutineScope)
Performs ChatClient.queryChannel with watch = true under the hood and returns ChannelState associated with the query. The ChannelState cannot be created before connecting the user therefore, the method returns a StateFlow that emits a null when the user has not been connected yet and the new value every time the user changes.
- Parameters:
cid- The full channel id, i.e.messageLimit- The number of messages that will be initially loaded.coroutineScope- The CoroutineScope used for executing the request.
-
watchChannelAsState
final static StateFlow<ChannelState> watchChannelAsState(ChatClient $self, String cid, Integer messageLimit)
Performs ChatClient.queryChannel with watch = true under the hood and returns ChannelState associated with the query. The ChannelState cannot be created before connecting the user therefore, the method returns a StateFlow that emits a null when the user has not been connected yet and the new value every time the user changes.
- Parameters:
cid- The full channel id, i.e.messageLimit- The number of messages that will be initially loaded.
-
queryThreadsAsState
final static StateFlow<QueryThreadsState> queryThreadsAsState(ChatClient $self, QueryThreadsRequest request, CoroutineScope coroutineScope)
Performs ChatClient.queryThreadsResult under the hood and returns QueryThreadsState. The QueryThreadsState cannot be created before connecting the user therefore, the method returns a StateFlow that emits a null when the user has not been connected yet and the new value every time the user changes.
- Parameters:
request- The QueryThreadsRequest used to perform the query threads operation.
-
getRepliesAsState
final static ThreadState getRepliesAsState(ChatClient $self, String messageId, Integer messageLimit, Boolean olderToNewer, CoroutineScope coroutineScope)
Same class of ChatClient.getReplies, but provides the result as ThreadState
- Parameters:
messageId- The ID of the original message the replies were made to.messageLimit- The number of messages that will be initially loaded.olderToNewer- The flag that determines the order of the messages.coroutineScope- The CoroutineScope used for executing the request.
-
getRepliesAsState
final static ThreadState getRepliesAsState(ChatClient $self, String messageId, Integer messageLimit, Boolean olderToNewer)
Same class of ChatClient.getReplies, but provides the result as ThreadState
- Parameters:
messageId- The ID of the original message the replies were made to.messageLimit- The number of messages that will be initially loaded.olderToNewer- The flag that determines the order of the messages.
-
awaitRepliesAsState
final static ThreadState awaitRepliesAsState(ChatClient $self, String messageId, Integer messageLimit, Boolean olderToNewer)
Returns thread replies in the form of ThreadState, however, unlike getRepliesAsState it will return it only after the API call made to get replies has ended. Thread state will be returned regardless if the API call has succeeded or failed, the only difference is in how up to date the replies in the thread state are.
- Parameters:
messageId- The ID of the original message the replies were made to.messageLimit- The number of messages that will be initially loaded.olderToNewer- The flag that determines the order of the messages.
-
setMessageForReply
final static Call<Unit> setMessageForReply(ChatClient $self, String cid, Message message)
Set the reply state for the channel.
- Parameters:
cid- CID of the channel where reply state is being set.message- The message we want reply to.
-
downloadAttachment
final static Call<Unit> downloadAttachment(ChatClient $self, Context context, Attachment attachment, Function1<Attachment, Uri> generateDownloadUri, Function1<DownloadManager.Request, Unit> interceptRequest)
Downloads the selected attachment to the "Download" folder in the public external storage directory.
If a CDN is configured on this ChatClient, the download URL and headers are transformed via CDN.imageRequest (for images) or CDN.fileRequest (for other files) before the download is enqueued. CDN transformations are applied after generateDownloadUri and before interceptRequest, so custom interceptors can override CDN headers.
- Parameters:
context- The context used to access the DownloadManager.attachment- The attachment to download.generateDownloadUri- The function that generates the download URI for the attachment.interceptRequest- The function that intercepts the DownloadManager.Request before it's enqueued.
-
loadOlderMessages
final static Call<Channel> loadOlderMessages(ChatClient $self, String cid, Integer messageLimit)
Loads older messages for the channel.
- Parameters:
cid- The full channel id i.e.messageLimit- How many new messages to load.
-
loadNewerMessages
final static Call<Channel> loadNewerMessages(ChatClient $self, String channelCid, String baseMessageId, Integer messageLimit)
-
loadMessagesAroundId
final static Call<Channel> loadMessagesAroundId(ChatClient $self, String cid, String messageId)
Loads messages around the given message id.
- Parameters:
cid- The full channel id i.e.messageId- The id of the message around which we want to load messages.
-
cancelEphemeralMessage
final static Call<Boolean> cancelEphemeralMessage(ChatClient $self, Message message)
Cancels the message of "ephemeral" type. Removes the message from local storage and state.
- Parameters:
message- Theephemeralmessage to cancel.
-
getMessageUsingCache
final static Call<Message> getMessageUsingCache(ChatClient $self, String messageId)
Attempts to fetch the message from offline cache before making an API call.
- Parameters:
messageId- The id of the message we are fetching.
-
loadMessageById
final static Call<Message> loadMessageById(ChatClient $self, String cid, String messageId)
Loads message for a given message id and channel id.
- Parameters:
cid- The full channel id i.messageId- The id of the message.
-
loadNewestMessages
final static Call<Channel> loadNewestMessages(ChatClient $self, String cid, Integer messageLimit, Boolean userPresence)
Loads the newest messages of a channel.
- Parameters:
cid- The full channel id i.messageLimit- The number of messages to be loaded.userPresence- Flag to determine if the SDK is going to receive UserPresenceChanged events.
-
-
-
-