Skip to main content

Public Messages

Sends public messages to all users within a subscribed channel.

Call Information

SendPublicMessage(string channelId, string message) {}

Call Information Details

ParameterDescriptionType
channelIdSubscribed channel IDstring
messageMessage to sendstring

Callback Method Information

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

ChatInfoModel Class Information Details

ChatInfoModel Class stores channel and sender information.

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 SendMessage()
{
string channelId = "string";
string message = "string";
chatClient.SendPublicMessage(channelId, message);
}

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