Forward messages
Forward messages between channels to share information or facilitate collaboration.
Use Forward() on a message object or ForwardMessage() on a channel/chat object. Both produce the same result with different input parameters.
Additional info in the forwarded message
Forwarded messages include originalPublisher (original sender's user ID) and originalChannelId (source channel ID).
Method signature
- Blueprint
- C++ / Input parameters
-
Message->Forward()1Message->Forward(FString ChannelID); -
Channel->ForwardMessage()1Channel->ForwardMessage(UPubnubMessage* Message); -
Chat->ForwardMessage()1Chat->ForwardMessage(
2 UPubnubChannel* Channel,
3 UPubnubMessage* Message
4);
| Parameter | Required in Message->Forward() | Required in Channel->ForwardMessage() | Required in Chat->ForwardMessage() | Description |
|---|---|---|---|---|
ChannelIDType: FStringDefault: n/a | Yes | No | No | Unique identifier of the channel to which you want to forward the message. You can forward a message to the same channel on which it was published or to any other. |
ChannelType: UPubnubChannel*Default: n/a | No | No | Yes | Channel object to which you want to forward the message. You can forward a message to the same channel on which it was published or to any other. |
MessageType: UPubnubMessage*Default: n/a | No | Yes | Yes | Message object that you want to forward to the selected channel. |
Output
These methods don't return any value.
Sample code
Forward a message from the support channel to the incident-management channel.
-
Forward()
show all 17 lines1
2#include "Kismet/GameplayStatics.h"
3#include "PubnubChatSubsystem.h"
4
5UGameInstance* GameInstance = UGameplayStatics::GetGameInstance(this);
6UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
7
8UPubnubChat* Chat = PubnubChatSubsystem ->InitChat("demo", "demo", "my_user");
9
10UPubnubChannel* Channel = Chat->GetChannel("support");
11
12FString Timetoken = "16200000000000001";
13
14// Fetch the message
15UPubnubMessage* Message = Channel->GetMessage(Timetoken); -
ForwardMessage()
show all 17 lines1#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");
10UPubnubChannel* Channel2 = Chat->GetChannel("incident-management");
11
12FString Timetoken = "16200000000000001";
13
14// Fetch the message
15UPubnubMessage* Message = Channel->GetMessage(Timetoken);