本文整理匯總了C#中Mooege.Net.MooNet.MooNetClient.SendServerMessage方法的典型用法代碼示例。如果您正苦於以下問題:C# MooNetClient.SendServerMessage方法的具體用法?C# MooNetClient.SendServerMessage怎麽用?C# MooNetClient.SendServerMessage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Mooege.Net.MooNet.MooNetClient
的用法示例。
在下文中一共展示了MooNetClient.SendServerMessage方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: TryParse
/// <summary>
/// Tries to parse given line as a server command.
/// </summary>
/// <param name="line">The line to be parsed.</param>
/// <param name="invokerClient">The invoker client if any.</param>
/// <param name="respondOver">The response medium to command</param>
/// <returns><see cref="bool"/></returns>
public static bool TryParse(string line, MooNetClient invokerClient, RespondOver respondOver)
{
string output = string.Empty;
string command;
string parameters;
var found = false;
if (!ExtractCommandAndParameters(line, out command, out parameters))
return false;
foreach(var pair in CommandGroups)
{
if (pair.Key.Name != command) continue;
output = pair.Value.Handle(parameters, invokerClient);
found = true;
break;
}
if (found == false)
output = string.Format("Unknown command: {0} {1}", command, parameters);
if (output == string.Empty) return true;
switch (respondOver)
{
case RespondOver.Channel: // if invoked from client within a channel
if (invokerClient != null) invokerClient.SendServerMessage(output);
break;
case RespondOver.Whisper: // if invoked from client with a whisper
if (invokerClient != null) invokerClient.SendServerWhisper(output);
break;
}
return true;
}