Properties - Android
A PubSubMessage is one message delivered to a PubSubMessageListener. Read its fields as Kotlin properties. All of them except timestamp are nullable, so handle null when you read them:
val text = message.message ?: ""
val isMine = message.senderId == room.localParticipant.id
id
-
type:
String? -
idis the unique id of the pubsub message.
message
-
type:
String? -
messageis the message that has been published on the specific topic.
topic
-
type:
String? -
topicis the name of the message topic.
senderId
-
type:
String? -
senderIdis the id of the participant who has sent the message. Compare it withroom.localParticipant.idto tell your own messages from everyone else's.
senderName
-
type:
String? -
senderNameis the name of the participant who has sent the pubsub message.
timestamp
-
type:
String -
timestampis the time at which the server accepted the pubsub message, exactly as the server sent it: an ISO-8601 UTC string such as2026-10-05T09:30:00.000Z. It is an empty string if the server sent none. -
To get a time value, parse it, for example with
java.time.Instant.parse(message.timestamp)(API level 26 and above). Check for an empty string first.
payload
-
type:
JSONObject? -
payloadis the data sent along with the message, ornullif none was sent.
Got a Question? Ask us on discord

