On this page

Typing indicator

Typing indicators show users when someone is composing a message. This feature:

  • Increases engagement - Users see activity in group chats
  • Sets expectations - Users know when to expect a response in 1:1 conversations
icon

Usage in Blueprints and C++


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 the typing indicator on a channel.

The method uses a debounce mechanism: signals are sent at intervals rather than on every keystroke. The default timeout is 5000 ms (5 seconds), with a 1000 ms buffer to prevent rapid re-triggering.

Custom timeout

Set a custom timeout with the typingTimeout parameter during initialization.

Method signature

Output

This method doesn't return any value.

Sample code

Start a typing indicator on the incident-management channel.

1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("incident-management");
10
11Channel->StartTyping();

Stop typing

StopTyping() deactivates the typing indicator on a channel.

Use this method to disable the typing indicator immediately (for example, when a user deletes a draft message) without waiting for the typingTimeout to end.

Method signature

Output

This method doesn't return any value.

Sample code

Stop a typing indicator on the incident-management channel.

1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("incident-management");
10
11Channel->StopTyping();

Get typing events

GetTyping() adds a signal events listener underneath to get all events of type typing. Run it once on a given channel to start listening to typing signals. You can also use it to get a list of typing user IDs. This method also returns a function you can invoke to stop receiving signal events and unsubscribe from the channel.

Method signature

GetTyping() accepts a callback function as an argument. The Unreal Chat SDK invokes this callback whenever someone starts/stops typing. This function takes a single argument of the list of currently typing user IDs.

icon

Handle the response


Output

TypeDescription
UPubnubCallbackStop*
Object on which you can call Stop() to stop receiving updates.

Sample code

Get a list of user IDs currently typing on the support channel.

1#include "Kismet/GameplayStatics.h"
2#include "PubnubChatSubsystem.h"
3
4UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
5UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
6
7UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
8
9UPubnubChannel* Channel = Chat->GetChannel("support");
10
11// Create a pubnub response delegate
12// you MUST implement your own callback function to handle the response
13FOnPubnubChannelTypingReceived TypingResponse;
14TypingResponse.BindDynamic(this, &AMyActor::OnTypingResponseReceived);
15
show all 16 lines

Other examples

Stop receiving signals on the support channel.

1auto StopUpdates = Channel->GetTyping();
2
3StopUpdates->Stop();
Last updated on