Example #1
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;
        }
 private void StopIdentServer( ) {
     if ( 0 == Interlocked.Decrement( ref _identServerUseCount ) ) {
         _identServer.Stop( );
         _identServer = null;
     }
 }
 private void StartIdentServer( ) {
     if ( 1 == Interlocked.Increment( ref _identServerUseCount ) ) {
         _identServer = new IdentServer( );
         _identServer.Start( );
     }
 }