Пример #1
0
        public ContinuousPingViewModel()
        {
            pingSender    = new PingSender();
            PingResponces = new ObservableCollection <ContinuousPing>();

            pingSender.AllPingsReceived     += (sender, args) => { UpdatePingResponces(args.PingResults); };
            PingResponces.CollectionChanged += (sender, args) => UpdatePingSenderList();

            TogglePings = new RelayCommand(() => { pingSender.Toggle(); });
        }
Пример #2
0
        static void Main(string[] args)
        {
            pingSender = new PingSender();

            pingSender.HostName = "www.google.com";
            pingSender.PingCompleted += PingSender_PingCompleted;
            Log("Start ping test");
            Log();
            SendPings(4);
            WaitForInput();
        }
Пример #3
0
    static void Main(string[] args)
    {
        NetworkStream stream;
        TcpClient irc;
        string inputLine;
        StreamReader reader;
        string nickname;

        try
        {
            irc=new TcpClient(SERVER,PORT);
            stream=irc.GetStream();
            reader=new StreamReader(stream);
            writer=new StreamWriter(stream);

            PingSender ping=new PingSender();
            ping.Start();

            writer.WriteLine(USER);
            writer.Flush();
            writer.WriteLine("NICK"+NICK);
            writer.Flush();
            writer.WriteLine("JOIN"+CHANNEL);
            writer.Flush();

            while(true)
            {
                while((inputLine=reader.ReadLine())!=null)
                {
                    if(inputLine.EndsWith("JOIN:"+CHANNEL))
                    {
                        nickname=inputLine.Substring(1,inputLine.IndexOf("!")-1);

                        writer.WriteLine("NOTICE"+nickname+":Hi"+nickname+" and welcome to "+CHANNEL+" channel! ");
                        writer.Flush();

                        Thread.Sleep(2000);
                    }
                }

                writer.Close();
                reader.Close();
                irc.Close();
            }
        }

        catch(Exception e)
        {
            Console.WriteLine(e.ToString());
            Thread.Sleep(5000);
            string[] argv={};
            Main(argv);
        }
    }
Пример #4
0
        static void Main(string[] args)
        {
            pingSender = new PingSender();

            pingSender.HostName       = "www.google.com";
            pingSender.PingCompleted += PingSender_PingCompleted;
            Log("Start ping test");
            Log();
            SendPings(4);
            WaitForInput();
        }
Пример #5
0
        private static async Task Main(string[] args)
        {
            var configuration = new ConfigurationBuilder()
                                .AddJsonFile("appsettings.json", false, true)
                                .AddEnvironmentVariables()
                                .AddCommandLine(args)
                                .Build();

            var startUp           = new StartUp(configuration);
            var serviceCollection = new ServiceCollection();

            startUp.ConfigureServices(serviceCollection);

            serviceCollection.AddTwitchClients(configuration.GetSection("twitch_api"));

            var serviceProvider = serviceCollection.BuildServiceProvider();

            var twitchClient           = serviceProvider.GetService <ITwitchIrcClient>();
            var messageParser          = serviceProvider.GetService <IMessageParser>();
            var processUserDataService = serviceProvider.GetService <IProcessUserDataService>();
            var ping = new PingSender(twitchClient);

            ping.Start();

            await twitchClient.SendPublicChatMessageAsync("Bot is active!");

            while (true)
            {
                var message = await twitchClient.ReadMessageAsync();

                if (!string.IsNullOrEmpty(message))
                {
                    Console.WriteLine((string)message);

                    var command = messageParser.GetCommandType(message);

                    switch (command)
                    {
                    case IrcCommand.PrivateMessage:
                        await processUserDataService.Process(message);

                        break;

                    default:
                        break;
                    }
                }
            }
        }
Пример #6
0
 /**
  * Function: StartBot()
  * Purpose:
  *  Starts the threads neccessary to run the bot.
  *
  */
 private void StartBot()
 {
     Debug.Log("Creating irc object....");
     _irc = new IRCClient(twitchIRCURL, twitchIRCPortNumber, twitchAccountName, twitchOAuthKey, ircChannelName);
     Debug.Log("Creating ping thread object....");
     _pingSender = new PingSender(_irc, pingDelayMillis);
     Debug.Log("Starting ping thread....");
     _pingSender.Start();
     Debug.Log("Creating chat polling thread object....");
     _chatGetter = new ChatGetter(_irc, chatPollDelayMillis);
     Debug.Log("Starting chat polling thread....");
     _chatGetter.Start();
     if (ONIRCConnected != null)
     {
         ONIRCConnected();
     }
 }
Пример #7
0
 public void TestXmlWriter()
 {
     Repository repo = new Repository();
     PingSender pingSender = new PingSender();
     ARPSender arpSender = new ARPSender();
     Task task1 = Task.Factory.StartNew( () =>
     {
         for( int i = 0 ; i < 10 ; i++ )
         {
             Task task2 = Task.Factory.StartNew( () =>
             {
                 repo.AddOrUpdate( IPAddress.Parse( "10.8.99.121" ), pingSender.Ping( IPAddress.Parse( "10.8.99.121" ) ) );
                 repo.AddOrUpdate( IPAddress.Parse( "10.8.99.121" ), arpSender.GetMac( IPAddress.Parse( "10.8.99.121" ) ) );
             } );
         }
         Thread.Sleep( 5000 );
     } ).ContinueWith( ( a ) =>
     {
         //pour le moment voir direct dans le dossier
         //repo.XmlWriter();
     } );
 }
Пример #8
0
    static void Main(string[] args)
    {
        WebClient wc = new WebClient();
        string src = wc.DownloadString("http://autowikibrowser.svn.sourceforge.net/viewvc/autowikibrowser/AWB/");
        string rx = "&amp;revision=([0-9]*)\">";
        startrev = Regex.Match(src, rx).ToString();
        startrev = startrev.Replace("&amp;revision=", "");
        startrev = startrev.Replace("\">", "");
       // int startrev1 = int.Parse(startrev) - 1;
       // startrev = startrev1.ToString();
        if (!stop)
        {
            try
            {
                ircClient = new TcpClient(server, port);
                ircConn = ircClient.GetStream();
                ircreader = new StreamReader(ircConn);
                ircwriter = new StreamWriter(ircConn);

                ircwriter.WriteLine(user);
                ircwriter.Flush();
                ircwriter.WriteLine("NICK " + botNick);
                ircwriter.Flush();

                ircwriter.WriteLine("JOIN " + channel);
                ircwriter.Flush();
                PingSender ping = new PingSender();
                ping.Start();

                CheckSVN svn = new CheckSVN();
                svn.Start();

                Console.WriteLine(ircConn);

                while (true)
                {
                    if (stop)
                    { break; }
                    ircwriter.WriteLine("NickServ zomg password");
                    ircwriter.Flush();

                    System.Timers.Timer timer = new System.Timers.Timer(90000);

                    //timerstart();
                //    pingtimerstart();

                    while ((inputLine = ircreader.ReadLine()) != null)
                    {
                        if (stop)
                        { break; }
                        string t = inputLine;
                        Console.WriteLine(t);

                        if (inputLine.Contains("!"))
                        {
                            Regex reg1 = new Regex(@"!(?<Code>\w+)$");
                            Match n = reg1.Match(inputLine);
                            if (n.Success == true)
                            {
                                string command = n.Groups[1].ToString(); //command
                                nickname = inputLine.Substring(1, inputLine.IndexOf("!") - 1);

                                talkNormal(command);
                            }
                        }

                    }
                }

            }

            #region exception handler
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                talkNormal("reset");
                stop = true;
            }
        }
    }
Пример #9
0
        public async Task RunAsync()
        {
            try
            {
                // ToDo: Check version number of application
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Error Message: {ex.Message}");
                Console.WriteLine();
                Console.WriteLine("Cannot connect to database to verify the correct version of myself");
                Console.WriteLine("Local troubleshooting needed by author of this bot");
                Console.WriteLine();
                Console.WriteLine("Shutting down now...");
                Thread.Sleep(5000);
                Environment.Exit(1);
            }

            try
            {
                // Configure error handler singleton class
                ErrorHandler.Configure(_broadcasterInstance.DatabaseId, _irc, _botConfig);

                // Get broadcaster ID so the user can only see their data from the db
                await SetBroadcasterIdsAsync();

                if (_broadcasterInstance.DatabaseId == 0 || string.IsNullOrEmpty(_broadcasterInstance.TwitchId))
                {
                    Console.WriteLine("Cannot find a broadcaster ID for you. "
                                      + "Please contact the author with a detailed description of the issue");
                    Console.WriteLine();
                    Console.WriteLine("Shutting down now...");
                    Thread.Sleep(5000);
                    Environment.Exit(1);
                }

                // Configure error handler singleton class
                ErrorHandler.Configure(_broadcasterInstance.DatabaseId, _irc, _botConfig);

                /* Connect to local Spotify client */
                _spotify = new SpotifyWebClient(_botConfig);
                await _spotify.ConnectAsync();

                /* Load command classes */
                _commandSystem = new CommandSystem(_irc, _botConfig, _appConfig, _bank, _songRequestBlacklist,
                                                   _libVLCSharpPlayer, _songRequestSetting, _spotify, _twitchInfo, _follower, _gameDirectory,
                                                   _ign, _manualSongRequest, _quote, _partyUp);

                /* Whisper broadcaster bot settings */
                Console.WriteLine();
                Console.WriteLine("---> Extra Bot Settings <---");
                Console.WriteLine($"Currency type: {_botConfig.CurrencyType}");
                Console.WriteLine($"Enable Auto Tweets: {_botConfig.EnableTweets}");
                Console.WriteLine($"Enable Auto Display Songs: {_botConfig.EnableDisplaySong}");
                Console.WriteLine($"Stream latency: {_botConfig.StreamLatency} second(s)");
                Console.WriteLine($"Regular follower hours: {_botConfig.RegularFollowerHours}");
                Console.WriteLine();

                /* Configure YouTube song request from user's YT account (request permission if needed) */
                await GetYouTubeAuthAsync();

                /* Start listening for delayed messages */
                DelayMessage delayMsg = new DelayMessage(_irc);
                delayMsg.Start();

                /* Grab list of chatters from channel */
                _twitchChatterListener.Start();

                /* Get the status of the Twitch stream */
                _twitchStreamStatus = new TwitchStreamStatus(_irc, _twitchInfo, _botConfig.Broadcaster);
                await _twitchStreamStatus.LoadChannelInfoAsync();

                _twitchStreamStatus.Start();

                /* Pull list of followers and check experience points for stream leveling */
                _followerSubscriberListener.Start(_irc, _broadcasterInstance.DatabaseId);

                /* Load/create settings and start the queue for the heist */
                await _bankHeistInstance.LoadSettings(_broadcasterInstance.DatabaseId, _botConfig.TwitchBotApiLink);

                _bankHeist.Start(_irc, _broadcasterInstance.DatabaseId);

                if (string.IsNullOrEmpty(TwitchStreamStatus.CurrentCategory))
                {
                    _irc.SendPublicChatMessage("WARNING: I cannot see the name of the game. It's currently set to either NULL or EMPTY. "
                                               + "Please have the chat verify that the game has been set for this stream. "
                                               + $"If the error persists, please have @{_botConfig.Broadcaster.ToLower()} retype the game in their Twitch Live Dashboard. "
                                               + "If this error shows up again and your chat can see the game set for the stream, please contact my master with !support in this chat");
                }

                // Grab game id in order to find party member
                TwitchGameCategory game = await _gameDirectory.GetGameIdAsync(TwitchStreamStatus.CurrentCategory);

                /* Load/create settings and start the queue for the boss fight */
                await _bossFightInstance.LoadSettings(_broadcasterInstance.DatabaseId, game?.Id, _botConfig.TwitchBotApiLink);

                _bossFight.Start(_irc, _broadcasterInstance.DatabaseId);

                /* Ping to twitch server to prevent auto-disconnect */
                PingSender ping = new PingSender(_irc);
                ping.Start();

                /* Send reminders of certain events */
                ChatReminder chatReminder = new ChatReminder(_irc, _broadcasterInstance.DatabaseId, _botConfig.TwitchBotApiLink, _twitchInfo, _gameDirectory);
                chatReminder.Start();

                /* Load in Twitch users that have bot moderation privileges (separate from channel moderators) */
                await _botModeratorInstance.LoadExistingModerators(_botConfig.TwitchBotApiLink, _broadcasterInstance.DatabaseId);

                /* Load in custom commands */
                await _customCommandInstance.LoadCustomCommands(_botConfig.TwitchBotApiLink, _broadcasterInstance.DatabaseId);

                /* Authenticate to Twitter if possible */
                GetTwitterAuth();

                Console.WriteLine("===== Time to get to work! =====");
                Console.WriteLine();

                /* Finished setup, time to start */
                await GetChatBoxAsync();
            }
            catch (Exception ex)
            {
                await _errHndlrInstance.LogError(ex, "TwitchBotApplication", "RunAsync()", true);
            }
        }
Пример #10
0
    static void Main(string[] args)
    {
        NetworkStream stream;
        TcpClient     irc;
        string        inputLine;

        loadCommands();

        try
        {
            irc = new TcpClient(SERVER, PORT);
            Console.WriteLine("Connected");
            stream = irc.GetStream();
            reader = new StreamReader(stream);
            writer = new StreamWriter(stream);

            writer.AutoFlush = true;

            // Start PingSender thread
            PingSender ping = new PingSender();
            ping.Start();

            writer.WriteLine("PASS " + PASS);
            //writer.Flush ();
            writer.WriteLine(USER);
            //writer.Flush ();
            writer.WriteLine("NICK " + NICK);
            //writer.Flush ();
            writer.WriteLine("JOIN " + CHANNEL);
            //writer.Flush ();

            Thread toDoThread = new Thread(new ThreadStart(readQueue));
            toDoThread.Start();

            Thread getTextThread = new Thread(new ThreadStart(getText));
            getTextThread.Start();

            while (true)
            {
                while ((inputLine = reader.ReadLine()) != null)
                {
                    //Write out all IRC input
                    //Console.WriteLine(inputLine);

                    processLine(inputLine);
                }

                // Close all streams
                writer.Close();
                reader.Close();
                irc.Close();
            }
        }
        catch (Exception e)
        {
            // Show the exception, sleep for a while and try to establish a new connection to irc server
            Console.WriteLine(e.ToString());
            Thread.Sleep(5000);
            string[] argv = { };
            Main(argv);
        }
    }
Пример #11
0
        public void Initialize()
        {
            Console.WriteLine("Initialize Connection");
            string inputLine = null;
            #if !DEBUG
            try
            {
            #endif
            using (var irc = new TcpClient(_server, _port))
            {

                var stream = irc.GetStream();
                var reader = new StreamReader(stream);
                _outputInterface.SetInterface(new StreamWriter(stream));
                // Start PingSender thread
                var ping = new PingSender(_outputInterface, _server);
                ping.Start();
                _outputInterface.WriteLine(User);
                _outputInterface.WriteLine("NICK " + _username);
                _outputInterface.WriteLine("JOIN " + _channel);
                while (true)
                {
                    while ((inputLine = reader.ReadLine()) != null)
                    {
                        Debug.WriteLine(inputLine);
                        var garbage = inputLine.Split(new[] {":"}, StringSplitOptions.RemoveEmptyEntries);
                        if (garbage.Length > 1)
                        {
                            var ircMessage = IrcMessage.ParseInput(inputLine);

                            foreach (var responder in _responders)
                            {
                                if (responder.HasResponse(ircMessage))
                                {
                                    var responses = responder.GetResponse(ircMessage);
                                    if (responses != null)
                                    {
                                        foreach (var response in responses)
                                        {
                                            Console.WriteLine("Input: {0}", inputLine);
                                            Console.WriteLine("Response: {0}", response);
                                            _outputInterface.WriteLine(response);
                                        }
                                    }
                                }
                            }
                        }
                    }
                    // Close all streams
                    _outputInterface.Close();
                    reader.Close();
                    irc.Close();
                }
            }
            #if !DEBUG
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                Console.WriteLine("Source: {0}",inputLine);
                Initialize();
            }
            #endif
        }
Пример #12
0
    static void Main(string[] args)
    {
        NetworkStream stream;
        TcpClient irc;
        string inputLine;

        loadCommands();

        try
        {
            irc = new TcpClient (SERVER, PORT);
            Console.WriteLine("Connected");
            stream = irc.GetStream ();
            reader = new StreamReader (stream);
            writer = new StreamWriter (stream);

            writer.AutoFlush = true;

            // Start PingSender thread
            PingSender ping = new PingSender ();
            ping.Start ();

            writer.WriteLine ("PASS " + PASS);
            //writer.Flush ();
            writer.WriteLine (USER);
            //writer.Flush ();
            writer.WriteLine ("NICK " + NICK);
            //writer.Flush ();
            writer.WriteLine ("JOIN " + CHANNEL);
            //writer.Flush ();

            Thread toDoThread = new Thread(new ThreadStart(readQueue));
            toDoThread.Start();

            Thread getTextThread = new Thread(new ThreadStart(getText));
            getTextThread.Start();

            while (true)
            {
                while ( (inputLine = reader.ReadLine () ) != null )
                {
                    //Write out all IRC input
                    //Console.WriteLine(inputLine);

                    processLine(inputLine);
                }

                // Close all streams
                writer.Close ();
                reader.Close ();
                irc.Close ();
            }
        }
        catch (Exception e)
        {
        // Show the exception, sleep for a while and try to establish a new connection to irc server
        Console.WriteLine (e.ToString () );
        Thread.Sleep (5000);
        string[] argv = { };
        Main (argv);
        }
    }
Пример #13
0
    // 主程序
    static void Main(string[] args)
    {
        NetworkStream stream;
        TcpClient     irc;
        string        inputLine;
        StreamReader  reader;
        string        nickname;

        try
        {
            irc    = new TcpClient(SERVER, PORT);
            stream = irc.GetStream();
            reader = new StreamReader(stream);
            writer = new StreamWriter(stream);

            // 开始PingSender进程
            PingSender ping = new PingSender();
            ping.Start();

            // 加入频道
            writer.WriteLine(USER);
            writer.Flush();
            writer.WriteLine("NICK " + NICK);
            writer.Flush();
            writer.WriteLine("JOIN " + CHANNEL);
            writer.Flush();

            while (true)
            {
                while ((inputLine = reader.ReadLine()) != null)
                {
                    if (inputLine.EndsWith("JOIN :" + CHANNEL))
                    {
                        // 读取频道内其它朋友的昵称
                        nickname = inputLine.Substring(1, inputLine.IndexOf("!") - 1);

                        // 和频道内所有的朋友打招呼
                        writer.WriteLine("NOTICE " + nickname + " :Hi " + nickname +
                                         " and welcome to " + CHANNEL + " channel!");
                        writer.Flush();

                        // Sleep以防止发包过快
                        Thread.Sleep(2000);
                    }
                }

                // 关闭所有的流
                writer.Close();
                reader.Close();
                irc.Close();
            }
        }
        catch (Exception e)
        {
            // 显示错误,sleep过后重新连接IRC服务器
            Console.WriteLine(e.ToString());
            Thread.Sleep(5000);
            string[] argv = { };
            Main(argv);
        }
    }
Пример #14
0
    static void Main(string[] argv)
    {
        TcpClient irc;
        NetworkStream stream;
        StreamReader reader;
        string[] command = "poop ".Split(' ');
        string inputLine = "", caller = "";

        //SERVER = argv[0];
        //CHANNEL = argv[1];

        while (true)
        {
            try
            {
                irc = new TcpClient(SERVER, PORT);
                stream = irc.GetStream();
                reader = new StreamReader(stream);
                writer = new StreamWriter(stream);
                PingSender ping = new PingSender();

                BaseFunctions.setNick(NICK);
                BaseFunctions.joinUser(NICK, NAME);
                BaseFunctions.joinChannel();

                // Start PingSender thread
                ping.Start();

                break;
            }
            catch (Exception e)
            {
                // Show the exception, sleep for a while and try to establish a new connection to irc server
                Console.WriteLine(e.ToString());
                Thread.Sleep(500);
            }
        }

        while (true)
        {
            try
            {
                inputLine = reader.ReadLine();
                //Console.WriteLine(inputLine);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                Console.WriteLine("\nError occured, quitting..");

                writer.Close();
                reader.Close();
                irc.Close();

                Environment.Exit(0);
            }

            if (parseMessage(inputLine, ref caller, ref command) == false) // HaHaHa, YAAnon can't code, doesn't he know he could've just put "!parseMessage..." - readability faggots.
                continue; //wait for another message

            Console.Write("{0} :", caller); // print out Nick calling the function + function name + args
            for (int i = 0; i < command.Length; i++)
                Console.Write("{0} ", command[i]);
            Console.WriteLine();

            switch (command[0])
            {
                case "?bbc":
                    bbcFunction.bbc(command);
                    break;

                case "?YAAB":
                    Functions.me(command);
                    break;

                case "?help":
                    Functions.help();
                    break;

                case "?quit":
                    if ((command.Length > 2 && Functions.authorise(command, caller)) == true) // if there's a reason, send it.
                        Functions.quit(writer, reader, irc, command);

                    else if (Functions.authorise(command, caller) == true) // else just quit
                        Functions.quit(writer, reader, irc);

                    break;

                default:
                    break;
            }
        }
    }
Пример #15
0
    static void Main()
    {
        string nickname, inputLine;

        try
        {
            // Start PingSender thread
            PingSender ping = new PingSender();
            ping.Start();
            userInput test = new userInput();
            test.start();

            writer.WriteLine("PASS " + PASS);
            writer.Flush();
            writer.WriteLine("NICK " + NICK);
            writer.Flush();
            writer.WriteLine("JOIN " + CHANNEL);
            writer.Flush();

            while (true)
            {
                while ((inputLine = reader.ReadLine()) != null)
                {
                    System.Diagnostics.Debug.WriteLine(inputLine);

                    string message  = "";
                    string userName = "";

                    string[] parts = inputLine.Split(' ');

                    switch (parts[1])
                    {
                    case "JOIN":
                        userName = parts[0].Substring(1, parts[0].IndexOf('!') - 1);
                        Users.onUserJoin(userName);
                        break;

                    case "PART":
                        userName = parts[0].Substring(1, parts[0].IndexOf('!') - 1);
                        Users.onUserLeft(userName);
                        break;

                    case "MODE":
                        foreach (User us in Users.list)
                        {
                            if (us.name == parts[4])
                            {
                                us.admin = true;
                                break;
                            }
                        }
                        break;

                    case "353":
                        for (int i = 5; i < parts.Length; i++)
                        {
                            if (i == 5)
                            {
                                Users.onUserJoin(parts[5].Substring(1));
                            }
                            else
                            {
                                Users.onUserJoin(parts[i]);
                            }
                        }
                        break;

                    case "PRIVMSG":
                        if (parts[0].Contains("jtv"))
                        {
                            break;
                        }

                        userName = parts[0].Substring(1, parts[0].IndexOf('!') - 1);
                        Users.onUserJoin(userName);

                        string tmp = "";
                        for (int i = 3; i < parts.Length; i++)
                        {
                            tmp += parts[i] + " ";
                        }

                        if (Users.isUserAdmin(userName))
                        {
                            if (userName == "monstercat")
                            {
                                writeLine(UppercaseFirst(userName) + " " + tmp, ConsoleColor.Cyan);
                            }
                            else
                            {
                                writeLine(UppercaseFirst(userName) + " " + tmp, ConsoleColor.Yellow);
                            }
                        }
                        else
                        {
                            writeLine(UppercaseFirst(userName) + " " + tmp);
                        }

                        // Now check if the user just sent a command
                        if (parts[3].StartsWith(":!"))
                        {
                            switch (parts.Length)
                            {
                            case 4:
                                Command.Check(userName, parts[3].Substring(2).ToLower());
                                break;

                            case 5:
                                Command.Check(userName, parts[3].Substring(2).ToLower(), parts[4].ToLower());
                                break;

                            case 6:
                                Command.Check(userName, parts[3].Substring(2).ToLower(), parts[4].ToLower(), parts[5].ToLower());
                                break;

                            case 7:
                                Command.Check(userName, parts[3].Substring(2).ToLower(), parts[4].ToLower(), parts[5].ToLower(), parts[6].ToLower());
                                break;

                            default:
                                // Else do nothing
                                break;
                            }
                        }
                        break;

                    default:
                        // Unknown message? Don't care, don't show it, it's in debug window anyways!
                        break;
                    }

                    #region Console Output/Send message
                    // Makes sure to not show/sends empty messages
                    if (message != "")
                    {
                        writer.WriteLine(message);
                        writer.Flush();
                    }
                    #endregion
                }

                // Close all streams
                writer.Close();
                reader.Close();
                irc.Close();
            }
        }
        catch (Exception e)
        {
            // Show the exception, sleep for a while and try to establish a new connection to irc server
            Console.WriteLine(e.ToString());
            Thread.Sleep(5000);
            Main();
        }
    }
Пример #16
0
        public void DeletePingAndRetreiveARPCache()
        {
            Console.WriteLine( "Before Deletion:" );
            Console.WriteLine( Arping.GetARPaResult() );

            Assert.That( Arping.DeleteCachedARP() == true, "ARP not deleted" );

            Console.WriteLine( "After Deletion:" );
            Console.WriteLine( Arping.GetARPaResult() );

            Option Option = new Option();
            Option.IpToTest = IPRange.AutoIpRange();
            PingSender pingSender = new PingSender( Option );
            ThreadPool.SetMinThreads( 200, 200 );
            Parallel.ForEach<int>( Option.IpToTest.Result, new ParallelOptions { MaxDegreeOfParallelism = 200 }, ipInt =>
            {
                IPAddress ip = IPAddress.Parse( ( (uint)ipInt ).ToString() );
                pingSender.AsyncPing( ip );
            } );
            Console.WriteLine( "After Ping" );
            Console.WriteLine( Arping.GetARPaResult() );
        }