Room

RoomService API

Get the roomService object through a login session

val roomService = session.roomService()

Create a one-on-one private chat room

Establishes a private chat room between two users.

suspend fun createDirectRoom(otherUserId: String): String

Input parameter:

NameTypeDescriptionRequired

otherUserId

string

ID of the other participant

true

Output parameter:

TypeDescriptionRequired

string

ID of the chat room

true

Create a general chat room

suspend fun createRoom(createRoomParams: CreateRoomParams): String

Input parameter:

NameTypeDescriptionRequired

createRoomParams

CreateRoomParams

Parameters for room creation

true

CreateRoomParams:

NameTypeDescription

name

string

Name of the room

topic

string

Topic of the room

avatarUri

Uri

URI for room avatar

invitedUserIds

string array

IDs of users to invite

preset

CreateRoomPreset

Specific room privacy settings

CreateRoomPreset:

ValueDescription

PRESET_PUBLIC_CHAT

Public room, joinable without an invitation

PRESET_PRIVATE_CHAT

Private room, joinable by invitation only

PRESET_TRUSTED_PRIVATE_CHAT

Private room, intended for one-on-one chats

Output parameter:

TypeDescriptionRequired

string

Room ID

true

Join a room

Join an existing room.

suspend fun joinRoom(
            roomId: String,
            reason: String? = null,
            viaServers: List<String> = emptyList()
    )

Input parameter:

NameTypeDescriptionRequired

roomId

string

Room ID

true

reason

string

Reason for joining

false

viaServers

string array

array of node domains

false

Output parameter:

TypeDescriptionRequired

string

Room ID

true

Leave a room

Leave an existing room.

suspend fun leaveRoom(roomId: String, reason: String? = null)

Input parameter:

NameTypeDescriptionRequired

roomId

string

Room ID

true

reason

string

Reason for leaving

false

Output parameter: None

Create a private chat Room with a wallet address

If a room already exists, it returns the existing room ID. If no room exists, a new room is created.

suspend fun createDmByWalletAddress(address: String): String

Input Parameter:

NameTypeDescriptionRequired

address

String

Target user's wallet address

true

Output parameter:

TypeDescriptionRequired

String

ID of the room

true

Delete a Room

This method allows the room owner to delete a room. Optional deletion reason can be provided.

suspend fun deleteRoom(roomId: String, reason: String? = null)

Input Parameter:

NameTypeDescriptionRequired

roomId

String

ID of the room

True

reason

String

Reason for deletion

False

Output parameter: None


RoomPushRuleService API

Get RoomPushRuleService object via Room object

val roomPushRuleService = room.roomPushRuleService()

Set Room Notification State

Modify the notification settings for a room.

suspend fun setRoomNotificationState(roomNotificationState: RoomNotificationState)

Input parameter:

NameTypeDescriptionRequired

roomNotificationState

RoomNotificationState

Notification state

true

RoomNotificationState values:

ValueDescription

ALL_MESSAGES

Notify for all messages

MENTIONS_ONLY

Notify only for mentions

MUTE

Disable notifications

Output parameter: None

Get room notification state

Get the current notification state of a room.

fun getLiveRoomNotificationState(): LiveData<RoomNotificationState>

Input parameter: None

Output parameter:

TypeDescriptionRequired

RoomNotificationState

Notification state

true


TagService API

Get TagService object via Room object

val tagService = room.tagService()

Add a room tag

Add a tag to a room with optional order.

suspend fun addTag(tag: String, order: Double?)

Input parameter:

NameTypeDescriptionRequired

tag

string

Name of the tag

true

order

double

Room Position, assigned a value from 0 to 1; lower values indicates higher priority.

false

Output parameter: None

Delete a Tag

Remove a tag from a room.

suspend fun deleteTag(tag: String)

Input parameter:

NameTypeDescriptionRequired

tag

string

Name of the tag

true

Output parameter: None


SendService API

Get SendService object via room object

val sendService = room.sendService()

Send a text message

Send a text message to a room.

    fun sendTextMessage(
            text: CharSequence,
            msgType: String = MessageType.MSGTYPE_TEXT,
            autoMarkdown: Boolean = false,
            additionalContent: Content? = null,
    ): Cancelable

Input parameter:

NameTypeDescriptionRequired

text

string

The content of the message

true

msgType

string

The type of message, default is text

true

autoMarkdown

boolean

Enable Markdown formatting, default is false

true

additionalContent

Content

Additional message content

false

Output parameter:

TypeDescriptionRequired

Cancelable

A cancelable object

true

Send media file

Send a media file to a room.

    fun sendMedia(
            attachment: ContentAttachmentData,
            compressBeforeSending: Boolean,
            roomIds: Set<String>,
            rootThreadEventId: String? = null,
            relatesTo: RelationDefaultContent? = null,
            additionalContent: Content? = null,
    ): Cancelable

Input parameter:

NameTypeDescriptionRequired

attachment

String

the media to send

true

compressBeforeSending

String

set to true to compress images before sending them

True

roomIds

String

set of roomIds to where the media will be sent. The current roomId will be add to this set if not present.

True

rootThreadEventId

String

when this param is not null, the Media will be sent in this specific thread

True

relatesTo

String

add a relation content to the media event

True

additionalContent

String

additional content to put in the event content

True

Output parameter:

TypeDescriptionRequired

Cancelable

A cancelable object

true


LocationSharingService API

Get LocationSharingService object via Room object

val locationSharingService = room.locationSharingService()

Send static location message

Share a static location in a room.

suspend fun sendStaticLocation(latitude: Double, longitude: Double, uncertainty: Double?, isUserLocation: Boolean): Cancelable

Input parameter:

NameTypeDescriptionRequired

latitude

double

Latitude coordinate

true

longitude

double

Longitude coordinate

true

uncertainty

double

Location accuracy in meters

false

isUserLocation

boolean

Indicates if the location is the user's current or a pinned location

true

Output parameter:

TypeDescriptionRequired

Cancelable

A cancelable object

true

Send live location message

Share a live location update in a room.

suspend fun sendLiveLocation(beaconInfoEventId: String, latitude: Double, longitude: Double, uncertainty: Double?): Cancelable

Input parameter:

NameTypeDescriptionRequired

beaconInfoEventId

string

Event ID of the initial beacon info state event

true

latitude

double

Latitude coordinate

true

longitude

double

Longitude coordinate

true

uncertainty

double

Location accuracy in meters

false

Output parameter:

TypeDescriptionRequired

Cancelable

A cancelable object

true

Last updated