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.

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 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 Unreal Chat SDK has a default typing timeout set to 5000 milliseconds (5 seconds) during the Unreal Chat SDK initialization. The StartTyping() method substracts 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 Unreal Chat SDK configuration (Init() method) using the typingTimeout parameter.

Method signature

Output

This method doesn't return any value.

Basic usage

Start a typing indicator on the incident-management channel.

#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();

UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");

UPubnubChannel* Channel = Chat->GetChannel("incident-management");

Channel->StartTyping();

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 without waiting for the typingTimeout to end.

Method signature

Output

This method doesn't return any value.

Basic usage

Stop a typing indicator on the incident-management channel.

#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();

UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");

UPubnubChannel* Channel = Chat->GetChannel("incident-management");

Channel->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.

Basic usage

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

#include "Kismet/GameplayStatics.h"
#include "PubnubChatSubsystem.h"

UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();

UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");

UPubnubChannel* Channel = Chat->GetChannel("support");

// Create a pubnub response delegate
// you MUST implement your own callback function to handle the response
FOnPubnubChannelTypingReceived TypingResponse;
TypingResponse.BindDynamic(this, &AMyActor::OnTypingResponseReceived);

show all 16 lines

Other examples

Stop receiving signals on the support channel.

auto StopUpdates = Channel->GetTyping();

StopUpdates->Stop();
Last updated on