Join channels
Join()
connects a user to a given channel and sets membership - this way, the chat user can both watch the channel's content and be its full-fledged member.
Requires App Context
To set up and manage channel membership, you must enable App Context for your app's keyset in the Admin Portal.
Method signature
Join()
accepts a callback function and a set of parameters as arguments. The Unreal Chat SDK invokes this callback whenever the current user receives a new message on a channel they have just joined. It subscribes the user to a channel and adds a message event listener underneath. The method also sets user and channel membership by creating a new Membership
object that holds the user-channel relation.
- Blueprint
- C++ / Input parameters
Channel->Join(
FOnPubnubChannelMessageReceived MessageCallback,
FString CustomData = ""
);
Parameter | Type | Required | Default | Description |
---|---|---|---|---|
MessageCallback | FOnPubnubChannelMessageReceived | Yes | n/a | Callback function passed as a parameter. It defines the custom behavior to be executed when detecting a new Message object on the joined channel. |
CustomData | FString | No | n/a | Any custom properties or metadata associated with the channel-user membership in the form of a JSON. Values must be scalar only; arrays or objects are not supported. App Context filtering language doesn’t support filtering by custom properties. |
Output
This method doesn't return any value.
Basic usage
Join 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
FOnPubnubChannelMessageReceived MessageCallback;
MessageCallback.BindDynamic(this, &AMyActor::OnMessageReceived);
show all 16 lines