本文整理汇总了C#中IConnection.SendLine方法的典型用法代码示例。如果您正苦于以下问题:C# IConnection.SendLine方法的具体用法?C# IConnection.SendLine怎么用?C# IConnection.SendLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IConnection
的用法示例。
在下文中一共展示了IConnection.SendLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SendServer
public static void SendServer(IConnection con)
{
// only for testing
Console.WriteLine("SEND SERVER COMMAND");
con.SendLine("PASS password 0211010001 IRC|aEFJKMRTu P");
con.SendLine("SERVER host3.irc.org 1 000C :Example Geographic L");
}
示例2: ProcessCommand
// TODO: support für server strings
// der erste parameter ist _immer_ das prefix fals keines vorhanden bleit der platz frei
public override bool ProcessCommand(IConnection connection, string cmd)
{
if (cmd.Length == 0)
{
Console.WriteLine(this + ": " + connection.ID + " has sent an null request, cmd.Length: " + cmd.Length);
return true; // drop message
}
string[] lines = this._parser.ParseString(cmd);
if (lines == null)
return true; // drop message
foreach (string line in lines)
{
if (line.Length == 0)
continue;
Console.WriteLine(this.GetType().ToString() + " bearbeite " + line);// + ", Lenght: " + line.Length);
if (RFC2812.IsValidCommand(line))
{
string[] ar = this._parser.ParseLine(line);
if (ar.Length <= 1) // nur das prefix ist vorhanden
{
Console.WriteLine("drop invalide server message and sent an error");
connection.SendLine("ERROR :Invalide message");
return true; // drop
}
ar[1] = ar[1].ToLower(); // neu für server
if ((ar[0] != string.Empty) && (!this._server.IsServer((IRCConnection)connection)))
{
connection.SendLine("ERROR :Not allowed from a client");
}
// security
// if (this._server.IsRegistred(connection)) // TODO
// {
// }
// debugging
this._server.WriteArgs(ar);
if (this.InvokeHandler(connection, ar))
continue;
if (this.CallHandler(connection, ar))
continue;
return false; // drop group
}
}
return true;
#if false
/*
string search = string.Empty;
try
{
object[] obj = new object[2];
obj[0] = connection;
obj[1] = ar;
Type srv = this._server.GetType();
search = "m";
// ar[0] enthält entweder das prefix oder das commando
// achtung prefix sample: ":krys NICK syrk"
search += "_" + ar[1];
Console.WriteLine(this + ": invoke " + search);
srv.InvokeMember(search, // very fast
BindingFlags.DeclaredOnly |
BindingFlags.Public |
BindingFlags.NonPublic |
BindingFlags.Instance |
BindingFlags.InvokeMethod, null, this._server, obj);
}
catch (MissingMethodException me)
{
Console.WriteLine(this + ": InvokeMember() no match: " + search);
try
{
CommandHandler handler = this._server.GetHandler(ar[0]);
if (handler != null)
{
handler(connection as IRCConnection, ar);
}
else
{
Console.WriteLine(this + ": GetHandler() no match: " + search + "\n: ");
return false;
}
}
catch (Exception e)
{
Console.WriteLine("CommandHandler: " + e.ToString());
}
//.........这里部分代码省略.........
示例3: Begin
public override void Begin(IConnection connection)
{
Connection = connection;
_logger.ForContext("ConnectionId", Connection.Id);
Connection.SendLine("PAPERCUT");
}