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:

Name
Type
Description
Required

otherUserId

string

ID of the other participant

true

Output parameter:

Type
Description
Required

string

ID of the chat room

true

Create a general chat room

suspend fun createRoom(createRoomParams: CreateRoomParams): String

Input parameter:

Name
Type
Description
Required

createRoomParams

CreateRoomParams

Parameters for room creation

true

CreateRoomParams:

Name
Type
Description

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:

Value
Description

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:

Type
Description
Required

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:

Name
Type
Description
Required

roomId

string

Room ID

true

reason

string

Reason for joining

false

viaServers

string array

array of node domains

false

Output parameter:

Type
Description
Required

string

Room ID

true

Leave a room

Leave an existing room.

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

Input parameter:

Name
Type
Description
Required

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:

Name
Type
Description
Required

address

String

Target user's wallet address

true

Output parameter:

Type
Description
Required

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:

Name
Type
Description
Required

roomId

String

ID of the room

True

reason

String

Reason for deletion

False

Output parameter: None

Hide Room

Hides a room from the room list. The room will automatically reappear when a new message is received.

suspend fun hideRoom(roomId: String)

Input Parameter:

Name
Type
Description
Required

roomId

string

Room ID

true

Output Parameter: None

Show Room

Makes a previously hidden room visible again.

suspend fun showRoom(roomId: String)

Input Parameter:

Name
Type
Description
Required

roomId

string

Room ID

true

Output Parameter: None

Get Private Chat Room

Gets the existing private chat room with a specified user.

fun getExistingDirectRoomWithUser(otherUserId: String): String?

Input Parameter:

Name
Type
Description
Required

otherUserId

string

Private chat user ID

true

Output Parameter:

Type
Description
Required

string

Private chat room ID

false


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:

Name
Type
Description
Required

roomNotificationState

RoomNotificationState

Notification state

true

RoomNotificationState values:

Value
Description

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:

Type
Description
Required

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:

Name
Type
Description
Required

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:

Name
Type
Description
Required

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:

Name
Type
Description
Required

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:

Type
Description
Required

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:

Name
Type
Description
Required

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:

Type
Description
Required

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:

Name
Type
Description
Required

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:

Type
Description
Required

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:

Name
Type
Description
Required

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:

Type
Description
Required

Cancelable

A cancelable object

true

Last updated