Subscribe to Channel
Enter (subscribe to) a specific channel.
Method Information
| Item | Content |
|---|---|
| Method | AChatManager::GetInstance()->Subscribe(const FString& Channel, int32 PrevMessageCount = 0) |
| Callback | OnSubscribed(const FChatUserInfo& User) - Called when user enters |
Parameters
| Parameter | Type | Description |
|---|---|---|
| Channel | FString | Channel name to subscribe to |
| PrevMessageCount | int32 | Number of previous chat messages to fetch (default: 0) |
Code Example
void UMyGame::EnterChannel(const FString& ChannelName)
{
// Fetch previous 10 chat messages
AChatManager::GetInstance()->Subscribe(ChannelName, 10);
}
void UMyGame::OnSubscribed(const FChatUserInfo& User)
{
UE_LOG(LogTemp, Log, TEXT("%s entered"), *User.visitorName);
}