On this page

Watch channels

Use Connect() to receive messages on a channel without joining as a member. The method subscribes to a message event listener and returns a function to disconnect.

icon

Usage in Blueprints and C++


Method signature

icon

Handle the response


Output

This method doesn't return any value.

Sample code

Start receiving messages on the support channel.

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 MessageResponse;
14MessageResponse.BindDynamic(this, &AMyActor::OnMessageResponseReceived);
15
show all 16 lines

Other examples

Stop receiving messages on the support channel.

1Channel->Disconnect();
Last updated on