Channel Subscription
The PlayNANOO chat service allows channels to be used by user groups or topics. Users who subscribe to a channel can receive all public messages.
Call Information
Subscribe(string channelId) {}
Subscribe(string channelId, short prevMessageCount) {}
Call Details
| Parameter | Description | Type |
|---|---|---|
| channelId | Subscription channel ID | string |
| prevMessageCount | Number of past messages to retrieve | string |
Callback Method Information
public void OnSubscribed(ChatInfoModel chatInfoModel) {}
ChatInfoModel Class Details
The ChatInfoModel Class contains information about the channel and user who sent the message.
| Data Key | Description | Type |
|---|---|---|
| gameId | Game ID | string |
| channelId | Channel ID | string |
| userUniqueId | User ID | string |
| userName | User name | string |
Source Code
using UnityEngine;
using PlayNANOO.ChatServer;
using PlayNANOO.ChatServer.Models;
public class PlayNANOOChatExample : MonoBehaviour, IChatListener
{
ChatClient chatClient;
void Start()
{
chatClient = new ChatClient(this);
chatClient.SetPlayer("USER_ID", "USER_NAME");
chatClient.Connect();
}
public void OnConntected()
{
chatClient.Subscribe("CHANNEL_ID");
}
public void OnSubscribed(ChatInfoModel chatInfo)
{
Debug.Log("User Joined");
}
}