Skip to main content

Private Messages

Sends private messages to connected friends.

Call Information

SendPrivateMessage(string friendUserId, string message) {}

Call Information Details

ParameterDescriptionType
friendUserIdFriend's user IDstring
messageMessage to sendstring

Callback Method Information

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

ChatInfoModel Class Information Details

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

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

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