Skip to main content

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

ParameterDescriptionType
channelIdSubscription channel IDstring
prevMessageCountNumber of past messages to retrievestring

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 KeyDescriptionType
gameIdGame IDstring
channelIdChannel IDstring
userUniqueIdUser IDstring
userNameUser namestring

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");
}
}