本文整理汇总了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;
}