TalkSession
This is the entry point to the TalkJS Kotlin Data API.
| constructor | |
| conversation | Get a reference to a conversation |
| onError | Attaches a handler that will be called when the session encounters an error Returns a callback which detaches your handler |
| subscribeConversations | Subscribes to the most recently active conversations for the current user |
| uploadAudio | Upload an audio file with audio-specific metadata. |
| uploadFile | Upload a generic file without any additional metadata. |
| uploadImage | Upload an image with image-specific metadata. |
| uploadVideo | Upload a video with video-specific metadata. |
| uploadVoice | Upload a voice recording with voice-specific metadata. |
| user | Get a reference to a user |
TalkSession(options)
Parameters
data class TalkSessionOptions
Your app's unique TalkJS ID. Get it from the Settings page of the dashboard.
A token to authenticate the session with. Ignored if a TalkSession object already exists for this appId + userId.
A callback that fetches a new token from your backend and returns it. If this callback throws an error, the session will terminate. Your callback should retry failed requests. Ignored if a TalkSession object already exists for this appId + userId.
The id of the user you want to connect and act as. Any messages you send will be sent as this user.
talkSession.onError(handler): Subscription
Attaches a handler that will be called when the session encounters an error
Returns a callback which detaches your handler
Parameters
Returns
talkSession.uploadAudio(data, metadata): String
Upload an audio file with audio-specific metadata.
This is a variant of TalkSession.uploadFile used for audio files.
Parameters
The binary audio data. Usually a File.
Information about the audio file.
Returns
A file token that can be used to send the audio file in a message.
talkSession.uploadFile(data, metadata): String
Upload a generic file without any additional metadata.
This function does not send any message, it only uploads the file and returns a file token. To send the file in a message, pass the file token in a when calling .
See the documentation for more information about sending files in messages.
If the file is a video, image, audio file, or voice recording, use one of the other functions like uploadImage instead.
Parameters
The binary file data. Usually a File.
Information about the file
Returns
A file token that can be used to send the file in a message.
talkSession.uploadImage(data, metadata): String
Upload an image with image-specific metadata.
This is a variant of TalkSession.uploadFile used for images.
Parameters
The binary image data. Usually a File.
Information about the image.
Returns
A file token that can be used to send the image in a message.
talkSession.uploadVideo(data, metadata): String
Upload a video with video-specific metadata.
This is a variant of TalkSession.uploadFile used for videos.
Parameters
The binary video data. Usually a File.
Information about the video.
Returns
A file token that can be used to send the video in a message.
talkSession.uploadVoice(data, metadata): String
Upload a voice recording with voice-specific metadata.
This is a variant of TalkSession.uploadFile used for voice recordings.
Parameters
The binary audio data. Usually a File.
Information about the voice recording.
Returns
A file token that can be used to send the audio file in a message.
Your app's unique TalkJS ID. Get it from the Settings page of the dashboard.
A token to authenticate the session with. Ignored if a TalkSession object already exists for this appId + userId.
A callback that fetches a new token from your backend and returns it. If this callback throws an error, the session will terminate. Your callback should retry failed requests. Ignored if a TalkSession object already exists for this appId + userId.
The id of the user you want to connect and act as. Any messages you send will be sent as this user.
The error that caused the subscription to be terminated
The name of the file including extension.
The name of the file including extension.
The height of the image in pixels, if known.
The width of the image in pixels, if known.
The duration of the video in seconds, if known.
The name of the file including extension.
The height of the video in pixels, if known.
The width of the video in pixels, if known.
The duration of the audio file in seconds, if known.
The name of the file including extension.
The duration of the recording in seconds, if known.
The name of the file including extension.