본문으로 건너뛰기

알림 메시지 수신

플레이나누 채팅 서비스는 공개, 비밀 메시지 외에 콘솔에서 알림 메시지 전송을 지원합니다.
콘솔에서 알림 메시지 전송을 할 경우 모든 사용자에게 메시지가 전송 됩니다.

콜백 메소드 정보

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

ChatInfoModel Class 상세정보

ChatInfoModel Class 에는 메시지를 전송한 채널 및 사용자 정보가 기록 되어있습니다.

데이터키설명타입
gameId게임 아이디string
channelId채널 아이디string
userUniqueId사용자 아이디string
userName사용자 이름string

소스 코드

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