Ejemplo n.º 1
0
        public override void Quit(string quitMessage)
        {
            base.Quit(quitMessage);

            _ircClient.Quit(quitMessage ?? "Quitting...");
            WebHostCancellationTokenHolder.CancellationTokenSource.Cancel();
        }
Ejemplo n.º 2
0
 public void Dispose()
 {
     if (_ircClient != null)
     {
         _ircClient.Quit(_clientTimeout, QuitMessage);
         _ircClient.Dispose();
     }
     GC.SuppressFinalize(this);
 }
Ejemplo n.º 3
0
 /// <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;
     }
 }
Ejemplo n.º 4
0
        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();
            }
        }
Ejemplo n.º 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;
        }
Ejemplo n.º 6
0
        public async Task Disconnect()
        {
            if (irc?.IsConnected != true)
            {
                return;
            }

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

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