-
- All Implemented Interfaces:
-
androidx.lifecycle.DefaultLifecycleObserver,androidx.lifecycle.LifecycleObserver,com.amazon.connect.chat.sdk.repository.ChatService
public final class ChatServiceImpl implements ChatService, DefaultLifecycleObserver
-
-
Field Summary
Fields Modifier and Type Field Description private final SharedFlow<ChatEventPayload>eventPublisherprivate final SharedFlow<TranscriptItem>transcriptPublisherprivate final SharedFlow<TranscriptData>transcriptListPublisherprivate final SharedFlow<Boolean>chatSessionStatePublisher
-
Constructor Summary
Constructors Constructor Description ChatServiceImpl(Context context, AWSClient defaultAwsClient, ConnectionDetailsProvider connectionDetailsProvider, WebSocketManager webSocketManager, MetricsManager metricsManager, AttachmentsManager attachmentsManager, MessageReceiptsManager messageReceiptsManager)
-
Method Summary
Modifier and Type Method Description SharedFlow<ChatEventPayload>getEventPublisher()SharedFlow<TranscriptItem>getTranscriptPublisher()SharedFlow<TranscriptData>getTranscriptListPublisher()SharedFlow<Boolean>getChatSessionStatePublisher()Unitconfigure(GlobalConfig config)ConnectionDetailsProvidergetConnectionDetailsProvider()Result<Boolean>createChatSession(ChatDetails chatDetails)Creates a chat session with the specified chat details. Result<Boolean>disconnectChatSession()Disconnects the current chat session. Result<Boolean>suspendWebSocketConnection()Disconnects the websocket and suspends reconnection attempts. Result<Boolean>resumeWebSocketConnection()Resumes a suspended websocket and attempts to reconnect. Result<Boolean>reset()Resets the current state which will disconnect the webSocket and remove all session related data without disconnecting the participant from the chat contact. Result<Boolean>sendMessage(ContentType contentType, String message)Sends a message. Result<Boolean>resendFailedMessage(String messageId)Retry a text message or attachment that failed to be sent. Result<Boolean>sendEvent(ContentType contentType, String content)Sends an event. UnitonStop(LifecycleOwner owner)Result<Boolean>sendAttachment(Uri fileUri)Sends an attachment. Result<URL>downloadAttachment(String attachmentId, String fileName)Downloads an attachment. Result<URL>getAttachmentDownloadUrl(String attachmentId)Returns the S3 download URL for an attachment. Result<TranscriptResponse>getTranscript(ScanDirection scanDirection, SortKey sortKey, Integer maxResults, String nextToken, StartPosition startPosition)Gets the transcript. Result<View>describeView(String viewToken)Retrieves the view for the specified view token. Result<Unit>sendMessageReceipt(MessageReceiptType messageReceiptType, String messageId)Sends a message receipt. -
-
Constructor Detail
-
ChatServiceImpl
ChatServiceImpl(Context context, AWSClient defaultAwsClient, ConnectionDetailsProvider connectionDetailsProvider, WebSocketManager webSocketManager, MetricsManager metricsManager, AttachmentsManager attachmentsManager, MessageReceiptsManager messageReceiptsManager)
-
-
Method Detail
-
getEventPublisher
SharedFlow<ChatEventPayload> getEventPublisher()
-
getTranscriptPublisher
SharedFlow<TranscriptItem> getTranscriptPublisher()
-
getTranscriptListPublisher
SharedFlow<TranscriptData> getTranscriptListPublisher()
-
getChatSessionStatePublisher
SharedFlow<Boolean> getChatSessionStatePublisher()
-
configure
Unit configure(GlobalConfig config)
-
getConnectionDetailsProvider
ConnectionDetailsProvider getConnectionDetailsProvider()
-
createChatSession
Result<Boolean> createChatSession(ChatDetails chatDetails)
Creates a chat session with the specified chat details.
- Parameters:
chatDetails- The details of the chat.
-
disconnectChatSession
Result<Boolean> disconnectChatSession()
Disconnects the current chat session.
-
suspendWebSocketConnection
Result<Boolean> suspendWebSocketConnection()
Disconnects the websocket and suspends reconnection attempts.
-
resumeWebSocketConnection
Result<Boolean> resumeWebSocketConnection()
Resumes a suspended websocket and attempts to reconnect.
-
reset
Result<Boolean> reset()
Resets the current state which will disconnect the webSocket and remove all session related data without disconnecting the participant from the chat contact.
-
sendMessage
Result<Boolean> sendMessage(ContentType contentType, String message)
Sends a message.
- Parameters:
contentType- The content type of the message.message- The message content.
-
resendFailedMessage
Result<Boolean> resendFailedMessage(String messageId)
Retry a text message or attachment that failed to be sent.
- Parameters:
messageId- The Id of the message that failed to be sent.
-
sendEvent
Result<Boolean> sendEvent(ContentType contentType, String content)
Sends an event.
- Parameters:
contentType- The content type of the message.content- The event content.
-
onStop
Unit onStop(LifecycleOwner owner)
-
sendAttachment
Result<Boolean> sendAttachment(Uri fileUri)
Sends an attachment.
-
downloadAttachment
Result<URL> downloadAttachment(String attachmentId, String fileName)
Downloads an attachment.
- Parameters:
attachmentId- The ID of the attachment.fileName- The name of the file.
-
getAttachmentDownloadUrl
Result<URL> getAttachmentDownloadUrl(String attachmentId)
Returns the S3 download URL for an attachment.
- Parameters:
attachmentId- The ID of the attachment.
-
getTranscript
Result<TranscriptResponse> getTranscript(ScanDirection scanDirection, SortKey sortKey, Integer maxResults, String nextToken, StartPosition startPosition)
Gets the transcript.
- Parameters:
scanDirection- The direction of the scan.sortKey- The sort key.maxResults- The maximum number of results.nextToken- The next token.startPosition- The start position.
-
describeView
Result<View> describeView(String viewToken)
Retrieves the view for the specified view token.
- Parameters:
viewToken- The view token from an interactive message.
-
sendMessageReceipt
Result<Unit> sendMessageReceipt(MessageReceiptType messageReceiptType, String messageId)
Sends a message receipt.
- Parameters:
messageReceiptType- The type of the message receipt.messageId- The ID of the message.
-
-
-
-