Message history
Unreal Chat SDK lets you fetch historical messages from one channel using the GetHistory()
method.
Due to current PubNub API limitations, you cannot filter the results by type, so you'll get all messages that happened on a given channel in a given timeframe.
Method signature
- Blueprint
- C++ / Input parameters
Channel->GetHistory(
int Limit,
FString Start,
FString End
);
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
Start | FString | No | n/a | Timetoken delimiting the start of a time slice (exclusive) to pull messages from. For details, refer to the Fetch History section. |
End | FString | No | n/a | Timetoken delimiting the end of a time slice (inclusive) to pull messages from. For details, refer to the Fetch History section. |
Limit | int | No | 25 | Number of historical messages to return for the channel in a single call. Since each call returns all attached message reactions by default, the maximum number of returned messages is 25 . |
Output
Parameter | Description |
---|---|
TArray<UPubnubMessage*> | Array listing the requested number of historical Message objects. |
By default, each call returns all message reactions and metadata attached to the retrieved messages.
Basic usage
From the support
channel, fetch 10
historical messages older than the timetoken 15343325214676133
.
#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");
// Define parameters for the GetHistory method
int Limit = 10;
FString StartTimetoken = "15343325214676133";
FString EndTimetoken; // Empty FString means no end timetoken will be used
show all 17 lines