OnChat
public ChatEventHandler OnChat;
Argument
Value | Type | Description |
---|---|---|
args | ChatEventArgs | Messages arrived at the connected channel / Errors occurred during message transmission |
ChatEventArgs
Value | Type | Description |
---|---|---|
ErrInfo | ErrorInfo | Success/failure information |
From | SessionInfo | Information on the chat message sender |
Message | string | Chat message content |
Description
This event is called when the user sends a message to the chat channel.
- It is called when the user themselves or another user sends a chat message.
In order for an event to be called, the message sending/receiving method must be called.
Example
// First way
Backend.Chat.OnChat = (ChatEventArgs args) =>
{
Debug.Log(string.Format("OnChat {0}", args.ErrInfo));
if(args.ErrInfo == ErrorInfo.Success)
{
// When the message belongs to you
if(!args.From.IsRemote)
{
Debug.Log("Me : " + args.Message);
}
// When the message belongs to another user
else
{
Debug.Log(string.Format("{0} : {1}", args.From.NickName, args.Message));
}
}
else if(args.ErrInfo.Category == ErrorCode.BannedChat)
{
// Spam prevention message
if(args.ErrInfo.Detail == ErrorCode.BannedChat)
{
Debug.Log("You have entered too many messages. Please try again after some time.");
}
}
};
// Second way
Backend.Chat.OnChat += (args) => {
// Same logic as the first way
}
Argument cases
When the chat message is received ErrInfo : ErrorInfo.Success
When the number of messages sent exceeds the spam prevention count set in BACKND Console ErrInfo.Category : ErrorCode.BannedChat ErrInfo.Detail : ErrorCode.BannedChat ErrInfo.Reason : "Spam prevention message that has been set"