ChatModels
Data model and interface definitions used in the chat system.
IChatListener Interface
Listener interface for receiving chat events.
| Method | Description |
|---|---|
| OnConnected | Called on successful server connection |
| OnDisconnected | Called on server disconnection |
| OnError | Called on error occurrence |
| OnChannels | Called when channel list is received |
| OnSubscribed | Called on channel subscription |
| OnUnSubscribed | Called on channel unsubscription |
| OnPublicMessage | Called when public message is received |
| OnPrivateMessage | Called when private message is received |
| OnNotifyMessage | Called when notification message is received |
| OnPlayerOnline | Called when player online status is received |
Data Models
ChatServerResponse
| Field | Type | Description |
|---|---|---|
| ErrorCode | string | Error code |
| Message | string | Message |
| Servers | ChatServerItem[] | Server list |
ChatServerItem
| Field | Type | Description |
|---|---|---|
| Addr | string | Server address |
| Port | int | Server port |
| Secure | string | SSL usage (Y/N) |
ChatMessageModel
| Field | Type | Description |
|---|---|---|
| mid | string | Message ID |
| type | byte | Event type |
| error | int | Error code |
| gameId | string | Game ID |
| serviceKey | string | Service key |
| channelId | string | Channel ID |
| userUniqueId | string | User unique ID |
| userName | string | Username |
| privateToUserUniqueId | string | Private message target ID |
| message | string | Message content |
| channels | ChatChannelInfo[] | Channel information array |
| players | ChatPlayerInfo[] | Player information array |
| onlinePlayers | string[] | Online player ID array |
| prevMessageCount | int | Number of previous messages to fetch |
| ipAddr | string | IP address |
| createdAt | string | Creation time |
ChatUserInfo
| Field | Type | Description |
|---|---|---|
| visitorId | string | Visitor ID |
| visitorName | string | Visitor name |
ChatChannelInfo
| Field | Type | Description |
|---|---|---|
| channel | string | Channel name |
| count | int | Number of users |
ChatPlayerInfo
| Field | Type | Description |
|---|---|---|
| userUniqueId | string | User unique ID |
| online | string | Online status |
Unity C# Implementation
using System;
public interface IChatListener
{
void OnConnected();
void OnDisconnected();
void OnError(string code, string message);
void OnChannels(ChatChannelInfo[] channels);
void OnSubscribed(ChatUserInfo user);
void OnUnSubscribed(ChatUserInfo user);
void OnPublicMessage(ChatUserInfo sender, string message);
void OnPrivateMessage(ChatUserInfo sender, string message);
void OnNotifyMessage(ChatUserInfo sender, string message);
void OnPlayerOnline(ChatPlayerInfo[] players);
}
[Serializable]
public class ChatServerResponse
{
public string ErrorCode;
public string Message;
public ChatServerItem[] Servers;
}
[Serializable]
public class ChatServerItem
{
public string Addr;
public int Port;
public string Secure;
}
[Serializable]
public class ChatMessageModel
{
public string mid;
public byte type;
public int error;
public string gameId;
public string serviceKey;
public string channelId;
public string userUniqueId;
public string userName;
public string privateToUserUniqueId;
public string message;
public ChatChannelInfo[] channels;
public ChatPlayerInfo[] players;
public string[] onlinePlayers;
public int prevMessageCount;
public string ipAddr;
public string createdAt;
}
[Serializable]
public class ChatUserInfo
{
public string visitorId;
public string visitorName;
}
[Serializable]
public class ChatChannelInfo
{
public string channel;
public int count;
}
[Serializable]
public class ChatPlayerInfo
{
public string userUniqueId;
public string online;
}