示例#1
0
        public void StartShouldThrowIfDisposed()
        {
            IdentServer server = new IdentServer(_userName);

            server.Dispose();
            server.Start();
        }
示例#2
0
 private void StartIdentServer( )
 {
     if (1 == Interlocked.Increment(ref _identServerUseCount))
     {
         _identServer = new IdentServer( );
         _identServer.Start( );
     }
 }
示例#3
0
        public void Stop_DoNotDisposeListener()
        {
            IdentServer.UserNameNeeded += (s, e) => e.UserName = "******";

            var client   = new TestTcpWrapper();
            var listener = new TestTcpListenerWrapper();

            IdentServer.Start(listener);
            IdentServer.Stop(false);
            Assert.IsFalse(listener.Disposed);
        }
示例#4
0
        public void Stop_DisposeListener()
        {
            IdentServer.UserNameNeeded += (s, e) => e.UserName = "******";

            var client   = new TestTcpWrapper();
            var listener = new TestTcpListenerWrapper();

            IdentServer.Start(listener);
            IdentServer.Stop();
            listener.AddClient(client);
            client.ReceiveLine("0,0");
            Assert.AreEqual(0, client.LinesSent.Count);
            Assert.IsTrue(listener.Disposed);
        }
示例#5
0
        private void Run(string[] args)
        {
#if DEBUG
            Debug.Listeners.Add(new CustomTraceListener( ));
#endif

            var ports = new Collection <int>( );
            foreach (var arg in args[1].Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries))
            {
                if ('+' == arg[0])
                {
                    IntHelper.TryParse(arg.Substring(1), _ => ports.Add(-_));
                }
                else
                {
                    IntHelper.TryParse(arg, ports.Add);
                }
            }

            Console.CancelKeyPress += ConsoleCancelKeyPress;

            _identServer = new IdentServer( );
            _identServer.Start( );

            _serverConnector = new ServerConnector(new ConnectionConfiguration {
                NickName         = "ZiveIrcTest",
                UserName         = "******",
                RealName         = "Testing instance of ZiveIrc. Contact: IceKarma",
                NickServPassword = "******",
                ServerHostName   = args[0],
                Ports            = ports,
            });

            _serverConnector.ConnectionEstablished    += ConnectionEstablished;
            _serverConnector.ConnectionAttemptStarted += ConnectionAttemptStarted;
            _serverConnector.ConnectionAttemptFailed  += ConnectionAttemptFailed;
            _serverConnector.ConnectionFailed         += ConnectionFailed;

            Console.WriteLine("Starting connection attempt.");
            _serverConnector.BeginConnect( );

            _doneEvent.WaitOne( );
            _doneEvent.Dispose( );
            _doneEvent = null;
        }
示例#6
0
文件: Main.cs 项目: Moones/OpenEnsage
 private void InitIrc()
 {
     statusBox.Items.Clear();
     if (_ircClient == null)
     {
         _ircClient = new IrcClient();
         _ircClient.Connected += new EventHandler(_ircClient_Connected);
         _ircClient.Closed += new EventHandler(_ircClient_Closed);
         _ircClient.GotJoinChannel += new EventHandler<JoinLeaveEventArgs>(_ircClient_GotJoinChannel);
         _ircClient.GotNotice += new EventHandler<ChatMessageEventArgs>(_ircClient_GotNotice);
         _ircClient.GotMessage += new EventHandler<ChatMessageEventArgs>(_ircClient_GotMessage);
         _ircClient.GotIrcError += new EventHandler<IrcErrorEventArgs>(_ircClient_GotIrcError);
         _ircClient.GotMotdEnd += new EventHandler(_ircClient_GotMotdEnd);
         _ircClient.GotNameListReply += new EventHandler<NameListReplyEventArgs>(_ircClient_GotNameListReply);
         _ircClient.GotLeaveChannel += new EventHandler<JoinLeaveEventArgs>(_ircClient_GotLeaveChannel);
         _ircClient.GotUserKicked += new EventHandler<KickEventArgs>(_ircClient_GotUserKicked);
     }
     if (_identServer == null)
     {
         try
         {
             _identServer = new IdentServer()
             {
                 UserID = _ircNickname
             };
             _identServer.Start(113);
         }
         catch (Exception)
         {
             statusBox.Items.Add("Couldn't start the ident server, this might be because you are already running another client");
         }
     }
     if (_ircClient.IsConnected)
         return;
     try
     {
         enterChatButton.Enabled = false;
         statusBox.Items.Add("Connecting...");
         _ircClient.Connect("irc.rizon.net", 6697, new IrcClientConnectionOptions()
         {
             Ssl = true,
             SslHostname = "irc.rizon.net",
             SslCertificateValidationCallback = new RemoteCertificateValidationCallback(ValidateSSL)
         });
     }
     catch (Exception ex)
     {
         enterChatButton.Enabled = true;
         statusBox.Items.Add("Connect error: " + ex.Message);
     }
 }