Typing indicator
The typing indicator feature provides real-time feedback when someone is composing a message, enhancing the conversational flow. It helps in the following:
-
Active participation - within group chats or collaborative environments, a user can measure others' engagement levels based on typing indicators, encouraging active involvement and minimizing communication gaps.
-
Anticipating responses - when engaged in 1:1 conversations, a user can see if the other person is actively responding, helping manage expectations and reducing uncertainty regarding response times.
Not available for public chats
Typing indicator is disabled in public chats. If you try implementing this feature in a public channel type, you'll get the Typing indicators are not supported in Public chats error.
Start typing
StartTyping() activates a typing indicator on a given channel.
The method sets a flag (typingSent) to indicate that a typing signal is in progress and adds a timer to reset the flag after a specified timeout.
The Unity Chat SDK has a default typing timeout set to 5000 milliseconds (5 seconds) during the Unity Chat SDK initialization. The StartTyping() method subtracts 1000 milliseconds (1 second) from the default timeout to cause an intentional delay between typing signals ("debounce" period).
This debounce mechanism ensures that the system responds to a user's actual typing behavior without being overly sensitive to minor fluctuations, keypresses, or temporary pauses in typing. Thanks to that, the typing indicator reflects more deliberate typing actions rather than every keystroke.
Configure default timeout
You can change the default typing timeout and set your own value during the Unity Chat SDK configuration using the TypingTimeout parameter.
Method signature
This method has the following signature:
1channel.StartTyping()
Input
This method doesn't take any parameters.
Output
An awaitable Task<ChatOperationResult>.
Sample code
Start a typing indicator on the support channel.
1
Stop typing
StopTyping() deactivates a typing indicator on a given channel.
You can use this method in cases when you want to disable the typing indicator immediately.
Method signature
This method has the following signature:
1channel.StopTyping()
Input
This method doesn't take any parameters.
Output
An awaitable Task<ChatOperationResult>.
Sample code
Stop a typing indicator on the support channel.
1
Get typing events
Get up-to-date information about the real-time signals from typing users in the specified channel.
Use the StreamTyping() method to enable or disable typing event streaming on a channel, and the OnUsersTyping event to handle typing updates. These events let you constantly track who has started or stopped typing and visually represent that in your chat app through a typing indicator.
Method naming
Earlier versions used SetListeningForTyping() to enable streaming. This method has been superseded by StreamTyping(), though it remains available for backward compatibility.
Method signature
These methods take the following parameters:
-
StreamTyping()1channel.StreamTyping(bool stream) -
OnUsersTyping- Event signature1// event on the Channel entity
2public event Action<List<string>> OnUsersTyping;
3// needs a corresponding event handler
4void EventHandler(List<string> users)
Input
| Parameter | Required in StreamTyping() | Required in OnUsersTyping | Description |
|---|---|---|---|
streamType: boolDefault: n/a | Yes | n/a | Whether to start (true) or stop (false) listening to typing events on the channel. |
usersType: List<string>Default: n/a | No | Yes | List of typing user IDs. |
Output
These methods don't return a value. Typing updates are delivered through the OnUsersTyping event handler.
Sample code
Get typing events on the support channel.
1