本文整理汇总了C#中NetworkClient.OutInstantMessage方法的典型用法代码示例。如果您正苦于以下问题:C# NetworkClient.OutInstantMessage方法的具体用法?C# NetworkClient.OutInstantMessage怎么用?C# NetworkClient.OutInstantMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkClient
的用法示例。
在下文中一共展示了NetworkClient.OutInstantMessage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoStep
public bool DoStep(NetworkClient networkClient, GameClient client)
{
List<string> messages = new List<string>();
Packet[] packets = networkClient.InputQueue.PopAll(FromServer.IMS);
if (!networkClient.OutInstantMessages || packets.Length == 0)
{
return false;
}
foreach (Packet packet in packets)
{
string sMessages = packet["@m"];
messages.AddRange(sMessages.Split(new[] { "\n" }, StringSplitOptions.RemoveEmptyEntries));
}
if (messages.Count > 0)
{
networkClient.OutInstantMessage(string.Format("Instant message(s), {0} received:", messages.Count));
foreach (string message in messages)
{
string logMessage;
string[] messageParts = message.Split('\t');
//Switch IMS command type
switch (messageParts[1])
{
//Private IM
case "100":
{
logMessage = string.Format("\t• {0}. Private from [{1}]: {2}",
messageParts[0], messageParts[2], messageParts[3]);
break;
}
//Shop message
case "217":
{
logMessage = string.Format("\t• {0}. Was received Coins[{1}] from [{2}]. Target: {3}",
messageParts[0], messageParts[3], messageParts[4], messageParts[6]);
break;
}
default:
{
logMessage = message;
break;
}
}
//Play alert
_soundPlayer.Play();
networkClient.OutInstantMessage(logMessage);
}
//Clear all IMS on server
string clearIMS = Packet.BuildPacket(FromClient.CLEAR_IMS);
networkClient.SendData(clearIMS);
return true;
}
return false;
}