Chat object
The Chat object is your entry point to the Chat SDK after initialization. Use the Chat object to create and manage channels, users, messages, memberships, and other entities.
Key capabilities:
- Create and delete channels and users
- Track user presence across channels
- Send custom events
- Access the underlying Unreal SDK
Properties
The Chat object is returned and initialized by the following operation:
1UPubnubChatSubsystem* PubnubChatSubsystem = GameInstance->GetSubsystem<UPubnubChatSubsystem>();
2
3FPubnubChatInitChatResult InitResult = PubnubChatSubsystem->InitChat("demo", "demo", "my_user");
4UPubnubChat* Chat = InitResult.Chat;
The subsystem supports multiple simultaneous chat instances keyed by UserID. Retrieve a specific chat instance with GetChat(UserID).
To initialize the Unreal Chat SDK, you must provide three parameters: Publish Key, Subscribe Key, and User ID, while all other settings are optional. Read the Configuration page for details.
Methods
You can call the following methods on the Chat object.
Click on each method for more details.
CreateDirectConversation()CreateGroupConversation()CreatePublicConversation()CreateThreadChannel()CreateUser()DeleteChannel()DeleteUser()DisconnectSubscriptions()ForwardMessage()GetAccessManager()GetChannel()GetChannels()GetChannelSuggestions()GetCurrentUser()GetEventsHistory()GetPubnubClient()GetThreadChannel()GetUnreadMessagesCounts()GetUser()GetUsers()GetUserSuggestions()IsPresent()MarkAllMessagesAsRead()PinMessageToChannel()ReconnectSubscriptions()RemoveThreadChannel()SetRestrictions()UnpinMessageFromChannel()UpdateChannel()UpdateUser()WherePresent()WhoIsPresent()
Use case
For example, you can use the Chat object methods to: