On this page

Join channels

Requires App Context

Enable App Context on your keyset in the Admin Portal to manage memberships.

Use Join() to connect a user to a channel and create a membership. The user can receive messages and is recorded as a channel member.

icon

Usage in Blueprints and C++


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.

Output

This method doesn't return any value.

Sample code

Join the support channel and mark this membership as premium to add information about your support plan.

1#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");
10
11// Create a pubnub response delegate
12// you MUST implement your own callback function to handle the response
13FOnPubnubChannelMessageReceived MessageCallback;
14MessageCallback.BindDynamic(this, &AMyActor::OnMessageReceived);
15
show all 21 lines
Last updated on