비밀 메시지 송수신
현재 어플리케이션에 접속되어있는 친구에게 1:1 비밀 메시지를 전송합니다.
호출 정보
SendPrivateMessage(string friendUserId, string message) {}
호출 상세 정보
파라미터 | 설명 | 타입 |
---|---|---|
friendUserId | 친구 사용자 아이디 | string |
message | 전송 메시지 | string |
콜백 메소드 정보
public void OnPrivateMessage(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 SendPrivateMessage()
{
string friendUserId = "string";
string message = "string";
chatClient.SendPrivateMessage(friendUserId, message);
}
public void OnPrivateMessage(ChatInfoModel chatInfo, string message)
{
Debug.Log(message);
}
}