Watch channels

You can let users watch a given channel and its messages using the Connect() method, without the need to join the channel as members.

Under the hood, this method allows your app to receive messages on a given channel by subscribing it to a message event listener underneath to receive all message events of type text. This method also returns a function you can invoke to stop receiving message events and unsubscribe from the channel.

icon

Usage in Blueprints and C++


Method signature

icon

Handle the response


Output

This method doesn't return any value.

Basic usage

Start receiving messages on 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 MessageResponse;
MessageResponse.BindDynamic(this, &AMyActor::OnMessageResponseReceived);

show all 16 lines

Other examples

Stop receiving messages on the support channel.

Channel->Disconnect();
Last updated on