TalkSession

This is the entry point to the TalkJS Kotlin Data API.

class TalkSession

Method Overview

onError

Attaches a handler that will be called when the session encounters an error

Returns a callback which detaches your handler

user

Get a reference to a user

conversation

Get a reference to a conversation

subscribeConversations

Subscribes to the most recently active conversations for the current user

_isConnected
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.

uploadAudio

Upload an audio file with audio-specific metadata.

uploadVoice

Upload a voice recording with voice-specific metadata.

constructor

Properties

_authProvider
: AuthProvider
currentUser
: UserRef

onError

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

handler
: (Exception) -> Unit

Returns

Subscription

user

talkSession.user(id): UserRef

Get a reference to a user

Parameters

id
: String

The ID of the user that you want to reference

Returns

UserRef

conversation

talkSession.conversation(id): ConversationRef

Get a reference to a conversation

Parameters

id
: String

The ID of the conversation that you want to reference

Returns

ConversationRef

subscribeConversations

talkSession.subscribeConversations(onSnapshot): ConversationListSubscription

Subscribes to the most recently active conversations for the current user

Parameters

onSnapshot (optional)
: (List<ConversationSnapshot>, Boolean) -> Unit?

Returns

ConversationListSubscription

_isConnected

talkSession._isConnected(): Boolean

Returns

Boolean

uploadFile

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 {@linkcode SendFileBlock} when calling {@linkcode ConversationRef.send}.

{@link https://talkjs.com/docs/Reference/Concepts/Message_Content/#sending-message-content | 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 {@linkcode uploadImage} instead.

Parameters

data
: ByteArray

The binary file data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.

metadata
: GenericFileMetadata

Information about the file

Returns

String

uploadImage

talkSession.uploadImage(data, metadata): String

Upload an image with image-specific metadata.

This is a variant of {@linkcode TalkSession.uploadFile} used for images.

Parameters

data
: ByteArray

The binary image data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.

metadata
: ImageFileMetadata

Information about the image.

Returns

String

uploadVideo

talkSession.uploadVideo(data, metadata): String

Upload a video with video-specific metadata.

This is a variant of {@linkcode TalkSession.uploadFile} used for videos.

Parameters

data
: ByteArray

The binary video data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.

metadata
: VideoFileMetadata

Information about the video.

Returns

String

uploadAudio

talkSession.uploadAudio(data, metadata): String

Upload an audio file with audio-specific metadata.

This is a variant of {@linkcode TalkSession.uploadFile} used for audio files.

Parameters

data
: ByteArray

The binary audio data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.

metadata
: AudioFileMetadata

Information about the audio file.

Returns

String

uploadVoice

talkSession.uploadVoice(data, metadata): String

Upload a voice recording with voice-specific metadata.

This is a variant of {@linkcode TalkSession.uploadFile} used for voice recordings.

Parameters

data
: ByteArray

The binary audio data. Usually a {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/File | File}.

metadata
: VoiceRecordingFileMetadata

Information about the voice recording.

Returns

String

constructor

new TalkSession.constructor(options)

Parameters

options
: TalkSessionOptions