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


C# IrcClient.Dispose方法代码示例

本文整理汇总了C#中IrcDotNet.IrcClient.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# IrcClient.Dispose方法的具体用法?C# IrcClient.Dispose怎么用?C# IrcClient.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IrcDotNet.IrcClient的用法示例。


在下文中一共展示了IrcClient.Dispose方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Connect

        protected void Connect(string server, IrcRegistrationInfo registrationInfo)
        {
            var client = new IrcClient();
            client.FloodPreventer = new IrcStandardFloodPreventer(4, 2000);
            client.Connected += IrcClient_Connected;
            client.Disconnected += IrcClient_Disconnected;
            client.Registered += IrcClient_Registered;
            client.PingReceived += IrcClient_PingReceived;
            client.NetworkInformationReceived += IrcClient_OnNetworkInformationReceived;
            client.RawMessageReceived += IrcClient_OnRawMessageReceived;
            client.RawMessageSent += IrcClient_OnRawMessageSent;
            clientCount++;

            // Wait until connection has succeeded or timed out.
            using (var connectedEvent = new ManualResetEventSlim(false)) {
                client.Connected += (sender2, e2) => connectedEvent.Set();
                client.Connect(server, false, registrationInfo);
            //	client.Id = clientCount++;
                if (!connectedEvent.Wait(10000)) {
                    client.Dispose();
                    Console.WriteLine("Connection to '{0}' timed out.", server);
                    return;
                }
            }
            // Add new client to collection
            this.allClients.Add(client);

            Console.Out.WriteLine("Now connected to '{0}'.", server);
        }
开发者ID:quiznilo,项目名称:Zerobot,代码行数:29,代码来源:IrcBot.cs

示例2: Connect

        /// <summary>
        /// </summary>
        /// <param name="server">
        /// </param>
        /// <param name="registrationInfo">
        /// </param>
        protected void Connect(string server, IrcRegistrationInfo registrationInfo)
        {
            // Create new IRC client and connect to given server.
            var client = new IrcClient();
            client.FloodPreventer = new IrcStandardFloodPreventer(4, 2000);
            client.Connected += this.IrcClient_Connected;
            client.Disconnected += this.IrcClient_Disconnected;
            client.Registered += this.IrcClient_Registered;
            client.ProtocolError += this.IrcClient_ProtocolError;
            client.ChannelListReceived += this.client_ChannelListReceived;

            // Wait until connection has succeeded or timed out.
            using (var connectedEvent = new ManualResetEventSlim(false))
            {
                client.Connected += (sender2, e2) => connectedEvent.Set();
                client.Connect(server, false, registrationInfo);
                if (!connectedEvent.Wait(10000))
                {
                    client.Dispose();
                    ConsoleUtilities.WriteError("Connection to '{0}' timed out.", server);
                    return;
                }
            }

            // Add new client to collection.
            this.allClients.Add(client);

            Console.Out.WriteLine("Now connected to '{0}'.", server);
        }
开发者ID:gordonc64,项目名称:CellAO-NightPredator,代码行数:35,代码来源:IrcBot.cs

示例3: Start

        public static void Start(SteamID room)
        {
            _room = room;

            if (_started)
                return;

            _started = true;

            messageQueue = new Queue<Tuple<string, string>>();

            _client = new IrcClient();
               // _client.FloodPreventer = new IrcStandardFloodPreventer(4, 2000);
            _client.Connected += (sender, e) =>
                                     {
                                         Message("Connected. Waiting for registration...");

                                         var c = (IrcClient)sender;
                                         c.Channels.Join(IRCChannel);

                                         c.LocalUser.NoticeReceived += (sender2, e2) => Console.WriteLine(string.Format("Notice from {0}: {1}", e2.Source.Name, e2.Text));
                                         c.LocalUser.MessageReceived += (sender2, e2) => Message(string.Format("Received PM from {0}: {1}", e2.Source.Name, e2.Text));
                                         c.LocalUser.JoinedChannel += (sender2, e2) =>
                                                                          {
                                                                              Message(string.Format("Joined {0} - IRC Spy Mode engaged. {1}", e2.Channel.Name, e2.Comment));

                                                                              //Message("Topic: " + e2.Channel.Topic); //Nothing happens!
                                                                              //e2.Channel.GetTopic(); //This causes TopicChanged to be called twice!

                                                                              e2.Channel.UsersListReceived += (sender3, e3) => Message("Users: " + string.Join(", ", e2.Channel.Users.OrderBy(u => u.User.NickName).Select(u => u.User.IsOperator ? "@" : "" + u.User.NickName))); //OH GOD MY EYES
                                                                              e2.Channel.TopicChanged += (sender3, e3) => Message("Topic: " + e2.Channel.Topic);
                                                                              e2.Channel.UserKicked += (sender3, e3) => Message(string.Format("{0} was kicked from {1}. {2}", e3.ChannelUser.User.NickName, e2.Channel.Name, e2.Comment));
                                                                              e2.Channel.UserJoined += (sender3, e3) => Message(string.Format("{0} joined {1}. {2}", e3.ChannelUser.User.NickName, e2.Channel.Name, e2.Comment));
                                                                              e2.Channel.UserLeft += (sender3, e3) => Message(string.Format("{0} left {1}. {2}", e3.ChannelUser.User.NickName, e2.Channel.Name, e2.Comment));
                                                                              e2.Channel.MessageReceived += SendIRC;
                                                                              e2.Channel.NoticeReceived += (sender3, e3) => Console.WriteLine(string.Format("Notice from {0}: {1}", e3.Source.Name, e3.Text));
                                                                          };

                                         c.LocalUser.LeftChannel += (sender2, e2) => Message(string.Format("Left {0}. ({1})", e2.Channel.Name, e2.Comment));

                                     };

            _client.Disconnected += (sender, e) =>
                                        {
                                            Message("Disconnected for some reason.");
                                            Stop();
                                        };

            _client.Registered += (sender, e) => Message(string.Format("Registered. Joining {0}...", IRCChannel));

            using (var connectedEvent = new ManualResetEventSlim(false))
            {
                _client.Connected += (sender2, e2) => connectedEvent.Set();

                _client.Connect(IRCServer, false, new IrcUserRegistrationInfo
                                                      {
                                                          NickName = "AGOPBOT",
                                                          UserName = "AGOPBOAT",
                                                          Password = "AGOPVOMIT",
                                                          RealName = "Agopbot Shirinian"
                                                      });

                if (!connectedEvent.Wait(10000))
                {
                    _client.Dispose();
                    Message(string.Format("Connection to {0} timed out.", IRCServer));
                }
            }
        }
开发者ID:EIREXE,项目名称:discord,代码行数:69,代码来源:CmdIRC.cs


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