本文整理匯總了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;
}