Transient messages are fire-and-forget messages that are delivered to online recipients in real time but never stored on the CometChat server. They’re ideal for ephemeral interactions like game state updates, cursor positions, or temporary notifications.
When to Use Transient Messages
Use Case Why Transient? Live game state (player position, health) High frequency, no need to persist Cursor/pointer position in collaborative tools Ephemeral by nature ”User is looking at this” indicators Temporary UI state Temporary notifications No history needed Custom signaling between clients Low-latency, no storage overhead
Transient messages are not delivered to offline users and cannot be fetched from message history. If you need message persistence, use regular messages instead.
Send a Transient Message
Use SendTransientMessage on the Subsystem. This is a fire-and-forget call — there’s no success/failure callback.
Create an FCometChatTransientMessage struct
Set ReceiverId (user UID or group GUID), ReceiverType (user or group), and Data (your custom payload)
Call Send Transient Message on the CometChat Subsystem
void AMyActor :: SendGameState ( const FString & GroupGuid , const FString & StateJson )
{
UCometChatSubsystem * Chat = GetGameInstance ()-> GetSubsystem < UCometChatSubsystem > ();
FCometChatTransientMessage Message;
Message . ReceiverId = GroupGuid;
Message . ReceiverType = TEXT ( "group" );
Message . Data = StateJson; // e.g., {"type":"position","x":100,"y":200}
Chat -> SendTransientMessage (Message);
}
Receive Transient Messages
Bind to the OnTransientMessageReceived delegate to receive transient messages from other users.
Get a reference to the CometChat Subsystem
Bind to On Transient Message Received
The custom event receives an FCometChatTransientMessage with the sender, receiver info, and data payload
void AMyActor :: BeginPlay ()
{
Super :: BeginPlay ();
UCometChatSubsystem * Chat = GetGameInstance ()-> GetSubsystem < UCometChatSubsystem > ();
Chat -> OnTransientMessageReceived . AddDynamic ( this , & AMyActor ::HandleTransientMessage);
}
void AMyActor :: HandleTransientMessage ( const FCometChatTransientMessage & Message )
{
UE_LOG (LogTemp, Log, TEXT ( "Transient from %s : %s " ),
* Message . Sender . Name , * Message . Data );
// Parse the Data JSON and handle accordingly
// e.g., update another player's cursor position
}
FCometChatTransientMessage
Property Type Description ReceiverIdFStringReceiver UID (1:1) or GUID (group) ReceiverTypeFString"user" or "group"DataFStringCustom data payload (typically JSON) SenderFCometChatUserThe user who sent the message (populated on receive)
Message Flow
Data format : The Data field is a free-form string. We recommend using JSON so receivers can parse it easily. Define a schema for your transient message types (e.g., {"type":"cursor","x":100,"y":200}) so handlers can route by type.
Example: Player Position Sync
A common game pattern — broadcast player position to group members at high frequency:
On a Timer (e.g., every 0.1s), get the player’s world location
Serialize to JSON: {"type":"pos","x":...,"y":...,"z":...}
Call Send Transient Message to the game’s group GUID
On receive, parse the JSON and update the remote player’s position
// Send position every 100ms
void AMyActor :: BroadcastPosition ()
{
FVector Pos = GetActorLocation ();
FString Json = FString :: Printf (
TEXT ( "{ \" type \" : \" pos \" , \" x \" : %.1f , \" y \" : %.1f , \" z \" : %.1f }" ),
Pos . X , Pos . Y , Pos . Z );
FCometChatTransientMessage Msg;
Msg . ReceiverId = GameGroupGuid;
Msg . ReceiverType = TEXT ( "group" );
Msg . Data = Json;
GetGameInstance ()-> GetSubsystem < UCometChatSubsystem > ()-> SendTransientMessage (Msg);
}
// Receive and apply remote player position
void AMyActor :: HandleTransientMessage ( const FCometChatTransientMessage & Message )
{
// Parse JSON, update remote player actor position
// (implementation depends on your game's player management)
}
Next Steps
Real-Time Events See all real-time delegates including transient messages.
Advanced Configuration Control connection lifecycle for optimal performance.