本文整理汇总了C#中NetworkClient.OutChatMessage方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkClient.OutChatMessage方法的具体用法?C# NetworkClient.OutChatMessage怎么用?C# NetworkClient.OutChatMessage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkClient
的用法示例。
在下文中一共展示了NetworkClient.OutChatMessage方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoStep
public bool DoStep(NetworkClient networkClient, GameClient client)
{
DateTime now = DateTime.Now;
ChatMessage[] outChatMessages = _outChatMessages.Where(cm => cm.MessageTime <= now ).ToArray();
if (outChatMessages.Length > 0)
{
foreach (ChatMessage chatMessage in outChatMessages)
{
_outChatMessages.Remove(chatMessage);
//1: From, 2: To, 3: Type, 4: Message
string message = Packet.BuildPacket(FromClient.CHAT_MESSAGE,
Chat.POST, client.Login, chatMessage.Sender, chatMessage.Type,
chatMessage.Message);
networkClient.SendChatData(message);
//Play notification for private message
_soundPlayer.Play();
//Out chat message
string logMessage = string.Format("[{0}] {1} [{2}] {3}",
client.Login,
chatMessage.Type == ChatMessageType.Pivate ? "private" : "to",
chatMessage.Sender, chatMessage.Message);
networkClient.OutChatMessage(logMessage);
}
return true;
}
return false;
}
示例2: DoStep
public bool DoStep(NetworkClient networkClient, GameClient client)
{
Packet[] packets = networkClient.InputQueue.PopAll(FromServer.CHAT_MESSAGE);
if (!networkClient.OutChatMessages || packets.Length == 0)
{
return false;
}
foreach (Packet packet in packets)
{
//Get chat message data
string messageData = packet["@text"];
if (string.IsNullOrEmpty(messageData) || packet["@html"] == "1")
{
continue;
}
//Get sender name
string sender = _regexChatSender.Match(messageData).Groups["SENDER"].Value;
//Check if the message is private or personal
bool isPrivateMessage = false, isPersonalMessage = false;
MatchCollection matchesUsers = _regexChatUsers.Matches(messageData);
foreach (Match matchUser in matchesUsers)
{
string user = matchUser.Groups["USER"].Value;
if (user.Equals(client.Login, StringComparison.InvariantCultureIgnoreCase))
{
isPrivateMessage |= matchUser.Groups["PRIVATE"].Success;
isPersonalMessage |= matchUser.Groups["PERSONAL"].Success;
}
}
//Out only private or personal messages
if (isPrivateMessage || isPersonalMessage)
{
//Check if the message has more than one recipients
bool isMultiUserMessage = matchesUsers.Count > 1;
//Play notification for private message
if (isPrivateMessage)
{
_soundPlayer.Play();
}
//Get chat message content
string message = _regexChatMessage.Match(messageData).Groups["MESSAGE"].Value;
//Get full chat message content
string fullMessage = _regexChatFullMessage.Match(messageData).Groups["MESSAGE"].Value;
//Out full incoming chat message
networkClient.OutChatMessage(fullMessage);
//Post this message to the chat bot
GameSystemStep_ChatBot.AppendIncomingMessage(sender, isPrivateMessage,
isPersonalMessage, isMultiUserMessage, message);
}
}
return true;
}