示例#1
0
        public override void Quit(string quitMessage)
        {
            base.Quit(quitMessage);

            _ircClient.Quit(quitMessage ?? "Quitting...");
            WebHostCancellationTokenHolder.CancellationTokenSource.Cancel();
        }
示例#2
0
 public void Dispose()
 {
     if (_ircClient != null)
     {
         _ircClient.Quit(_clientTimeout, QuitMessage);
         _ircClient.Dispose();
     }
     GC.SuppressFinalize(this);
 }
示例#3
0
文件: IrcManager.cs 项目: syncore/SST
 /// <summary>
 /// Disconnects the client from the IRC server.
 /// </summary>
 public void Disconnect()
 {
     try
     {
         Log.Write("Closing IRC client connection.", _logClassType, _logPrefix);
         _client.Quit(_quitMessage);
     }
     catch (Exception)
     {
         // IrcDotNet: Client might already be disposed
     }
     finally
     {
         _reconnectTries = MaxReconnectionTries;
         StopIrcThread();
         IsConnectedToIrc = false;
     }
 }
        public void HandleCommands(string commandstring)
        {
            ConnectMethod(commandstring);

            if (commandstring.StartsWith("#/joinc"))
            {
                var channelname = commandstring.Replace("#/joinc", "").Trim();
                var selected    = myclient.Channels.First(item => item.Name == channelname);
                selected.MessageReceived += RecieveMessage;
                selected.NoticeReceived  += (sender, args) => { OutputLog += args.GetText(); };
                myclient.Channels.Join(channelname);
            }

            if (commandstring == ("#/quit"))
            {
                myclient.Quit("exiting");
                myclient.Dispose();
            }
        }
示例#5
0
        private void DisposeClient()
        {
            if (_client == null)
            {
                return;
            }

            if (_client.IsConnected)
            {
                _client.Quit(1000, "I'm outta here");
            }

            _client.ErrorMessageReceived -= OnClientErrorMessageReceived;
            _client.Connected            -= OnClientConnected;
            _client.ConnectFailed        -= OnClientConnectFailed;
            _client.Disconnected         -= OnClientDisconnected;
            _client.Registered           -= OnClientRegistered;
            _client.Error += OnError;
            _client.Dispose();
            _client = null;
        }
示例#6
0
        public async Task Disconnect()
        {
            if (irc?.IsConnected != true)
            {
                return;
            }

            try
            {
                {
                    cancellationTokenSource.Cancel();
                    await Task.WhenAll(messageDispatchers);
                }

                irc.Quit("QQ");
            }
            catch (Exception)
            {
                // ignored
            }
        }