当前位置: 首页>>代码示例>>C#>>正文


C# IConnection.SendLine方法代码示例

本文整理汇总了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");
 }
开发者ID:BackupTheBerlios,项目名称:storm-ircd-svn,代码行数:7,代码来源:IRCServerConnection.cs

示例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());
                        }
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:storm-ircd-svn,代码行数:101,代码来源:IRCInterpretor.cs

示例3: Begin

 public override void Begin(IConnection connection)
 {
     Connection = connection;
     _logger.ForContext("ConnectionId", Connection.Id);
     Connection.SendLine("PAPERCUT");
 }
开发者ID:priestd09,项目名称:Papercut,代码行数:6,代码来源:PapercutProtocol.cs


注:本文中的IConnection.SendLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。