Skip to main content

Receive Notification Messages

The PlayNANOO chat service supports sending notification messages from the console, in addition to public and private messages. When a notification message is sent from the console, the message is delivered to all users.

Callback Method Information​

public void OnNotifyMessage(ChatInfoModel chatInfo, string message) {}

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

void Update()
{
if (chatClient != null)
{
chatClient.Service();
}
}

public void OnConntected()
{
chatClient.Subscribe("CHANNEL_ID");
}

public void OnSubscribed(ChatInfoModel chatInfo)
{
Debug.Log("User Joined");
}

public void OnNotifyMessage(ChatInfoModel chatInfo, string message)
{
Debug.Log(message);
}
}