Typing indicator
The Nexconn SDK supports sending typing status in direct channels, allowing the UI to display "typing..." indicators.
tip
- Typing indicators are supported in direct channels only.
- The SDK rate-limits typing status to one message per 6 seconds per channel.
Send typing status
Use channel.sendTypingStatus() on a DirectChannel instance to notify the other user that the current user is typing.
- Kotlin
- Java
kotlin
val channel = DirectChannel("userId")
editText.addTextChangedListener(object : TextWatcher {
override fun afterTextChanged(s: Editable?) {
if (s?.isNotEmpty() == true) {
channel.sendTypingStatus("RC:TxtMsg")
}
}
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {}
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {}
})
Java
DirectChannel channel = new DirectChannel("userId");
editText.addTextChangedListener(new TextWatcher() {
@Override
public void afterTextChanged(Editable s) {
if (s != null && s.length() > 0) {
channel.sendTypingStatus("RC:TxtMsg");
}
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {}
});
Listen for typing status
Register a ChannelHandler using NCEngine.addChannelHandler() to receive typing status updates. The onTypingStatusChanged callback fires when the typing status of any participant in a channel changes.
- Kotlin
- Java
kotlin
NCEngine.addChannelHandler("TYPING_HANDLER", object : ChannelHandler {
override fun onTypingStatusChanged(event: TypingStatusChangedEvent) {
event.userTypingStatus.forEach { info ->
Log.d("Typing", "${info.userId} is typing: ${info.typingContentType}")
}
}
})
Java
NCEngine.addChannelHandler("TYPING_HANDLER", new ChannelHandler() {
@Override
public void onTypingStatusChanged(TypingStatusChangedEvent event) {
for (ChannelUserTypingStatusInfo info : event.getUserTypingStatus()) {
Log.d("Typing", info.getUserId() + " is typing: " + info.getTypingContentType());
}
}
});
Remove the listener
- Kotlin
- Java
kotlin
NCEngine.removeChannelHandler("TYPING_HANDLER")
Java
NCEngine.removeChannelHandler("TYPING_HANDLER");
ChannelUserTypingStatusInfo properties
| Property | Type | Description |
|---|---|---|
userId | String | The user ID of the participant who is typing. |
typingContentType | String | The message content type being composed. |
sentTime | Long | The timestamp (ms) when the typing status was sent. |
Parameters
sendTypingStatus
| Parameter | Type | Description |
|---|---|---|
typingMessageType | String | The message type identifier being typed (see table below). |
Common message type identifiers
| Message type | Identifier |
|---|---|
| Text message | RC:TxtMsg |
| Voice message | RC:VcMsg |
| Image message | RC:ImgMsg |
| File message | RC:FileMsg |
Important notes
- Typing indicators work in direct channels only.
- The SDK enforces a 6-second rate limit internally.
- Typing status is not persisted.
- Stop sending typing status when the user clears the input field.