Skip to main content
Version: 5.9.6

OnWhisper

public WhisperEventHandler OnWhisper;

Argument

ValueTypeDescription
argsWhisperEventArgsWhisper message information from other users

WhisperEventArgs

ValueTypeDescription
ErrInfoErrorInfoSuccess/failure information
FromSessionInfoInformation of the person who sent the whisper
ToSessionInfoInformation of the person who received the whisper
MessagestringWhisper message content

Description

Receives the whisper sent to you.

  • Receiving whisper messages is only available when connected to a general chat channel.

In order for an event to be called, the message sending/receiving method must be called.

Example

// First way
Backend.Chat.OnWhisper = (WhisperEventArgs args) =>
{
Debug.Log(string.Format("OnWhisper {0}", args.ErrInfo));

if(args.ErrInfo == ErrorInfo.Success)
{
Debug.Log(string.Format("OnWhisper: from {0} to {1} : message {2}", args.From.NickName, args.To.NickName, args.Message));

// When you sent the whisper
if(!args.From.IsRemote)
{
Debug.Log("Me : " + args.Message);
}
// When you received a whisper
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.OnWhisper += (args) => {
// Same logic as the first way
}