Watch channels
Use Connect() to receive messages on a channel without joining as a member. Connect() subscribes to the channel. Bind the OnMessageReceived delegate before calling Connect(). Messages are received via this delegate. Use Disconnect() to stop receiving messages.
Asynchronous and synchronous method execution
Most PubNub Unreal SDK methods are available in both asynchronous and synchronous variants.
-
Asynchronous methods (
Asyncsuffix) returnvoidand take an optional delegate parameter that fires when the operation completes.1Channel->ConnectAsync(OnConnectResponseDelegate);You can also use native callbacks that accept lambdas instead of dynamic delegates. Native callback types have the
Nativesuffix (for example,FOnPubnubChatOperationResponseNative). -
Synchronous methods (no suffix) block the main game thread until the operation completes and return a result struct directly.
1FPubnubChatOperationResult Result = Channel->Connect();
Method signature
- C++ / Input parameters
- Blueprint
1Channel->Connect();
Channel->Connect() takes no parameters and returns FPubnubChatOperationResult.
Output
| Type | Description |
|---|---|
FPubnubChatOperationResult | Contains Error (bool) and ErrorMessage (FString). Check Error to determine if the operation succeeded. |
Sample code
Reference code
This example is a self-contained code snippet ready to be run. Set up your Unreal project and follow the instructions in the lines marked with ACTION REQUIRED before running the code. Use it as a reference when working with other examples in this document.
Connect to a channel and start listening for messages.
Other examples
Stop receiving messages on the support channel.
- C++
- Blueprint
1