Class ChatClientExtensions
-
- All Implemented Interfaces:
public final class ChatClientExtensions
-
-
Field Summary
Fields Modifier and Type Field Description private final static StateRegistrystateprivate final static GlobalStateglobalState
-
Method Summary
Modifier and Type Method Description final StateRegistrygetState()final GlobalStategetGlobalState()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<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 ThreadStategetRepliesAsState(ChatClient $self, String messageId, Integer messageLimit, CoroutineScope coroutineScope)Same class of ChatClient. final static ThreadStategetRepliesAsState(ChatClient $self, String messageId, Integer messageLimit)Same class of ChatClient. final static ThreadStateawaitRepliesAsState(ChatClient $self, String messageId, Integer messageLimit)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)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<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()
-
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.- Returns:
A StateFlow object that emits a null when the user has not been connected yet and the new QueryChannelsState when the user changes.
-
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.- Returns:
A StateFlow object that emits a null when the user has not been connected yet and the new QueryChannelsState when the user changes.
-
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.- Returns:
A StateFlow object that emits a null when the user has not been connected yet and the new QueryChannelsState when the user changes.
-
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.- Returns:
A StateFlow object that emits a null when the user has not been connected yet and the new ChannelState when the user changes.
-
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.- Returns:
A StateFlow object that emits a null when the user has not been connected yet and the new ChannelState when the user changes.
-
getRepliesAsState
final static ThreadState getRepliesAsState(ChatClient $self, String messageId, Integer messageLimit, 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.coroutineScope- The CoroutineScope used for executing the request.- Returns:
-
getRepliesAsState
final static ThreadState getRepliesAsState(ChatClient $self, String messageId, Integer messageLimit)
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.- Returns:
-
awaitRepliesAsState
final static ThreadState awaitRepliesAsState(ChatClient $self, String messageId, Integer messageLimit)
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.- Returns:
ThreadState wrapped inside a Call.
-
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.- Returns:
Executable async Call.
-
downloadAttachment
final static Call<Unit> downloadAttachment(ChatClient $self, Context context, Attachment attachment)
Downloads the selected attachment to the "Download" folder in the public external storage directory.
- Parameters:
attachment- The attachment to download.- Returns:
Executable async Call downloading attachment.
-
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.- Returns:
The channel wrapped in Call. This channel contains older requested messages.
-
loadNewerMessages
final static Call<Channel> loadNewerMessages(ChatClient $self, String channelCid, String baseMessageId, Integer messageLimit)
-
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.- Returns:
Executable async Call responsible for canceling ephemeral message.
-
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.- Returns:
The message with the corresponding iID wrapped inside a Call.
-
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.- Returns:
Executable async Call responsible for loading a 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.- Returns:
Executable async Call responsible for loading the newest messages.
-
-
-
-