Links
Unreal Chat SDK lets you encode URLs that begin with www
, http
, or https
(plain links) so that they can be customized and rendered as clickable links. You can also let chat users create hyperlinks manually by replacing URLs in messages with descriptive texts (text links).
Add linked text
Use the SendText()
method with an additional TextLinks
param to create a link within a message.
Method signature
- Blueprint
- C++ / Input parameters
Channel->SendText(
FString Message,
FSendTextParams SendTextParams = FSendTextParams()
);
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
Message | FString | No | n/a | Text that you want to send to the selected channel. |
SendTextParams | FSendTextParams | No | n/a | Struct providing additional parameters. |
→ TextLinks | TArray<FPubnubTextLink> | No | n/a | Returned array of FPubnubTextLink (int Start_Index = 0 , int End_Index = 0 , FString Link = "" ) that are shown as text in the message. You can use this array to place a link in the proper position within a message. |
Output
This method doesn't return any value.
Basic usage
Add a link to https://www.support-article.com/
to a message.
#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");
FSendTextParams SendTextParams;
FPubnubTextLink TextLink({14, 44, "https://www.support-article.com/"});
SendTextParams.TextLinks.Add(TextLink);
Channel->SendText("Support page:", SendTextParams);
Get text links
TextLinks()
is a getter method that returns all text links in a given message.
Method signature
- Blueprint
- C++ / Input parameters
Message->TextLinks();
Output
Type | Description |
---|---|
TArray<FPubnubTextLink> | Array of text links included in the message. |
Basic usage
Get all text links included in the message with the 16200000000000000
timetoken.
#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");
FString Timetoken = "16200000000000001";
// Fetch the message
UPubnubMessage* Message = Channel->GetMessage(Timetoken);
show all 16 lines