Inheritance: Connection
Esempio n. 1
0
        void BotConnect(object aSender, EventArgs <Packet, Int64, IPAddress, int> aEventArgs)
        {
            int currentDownloadCount = (from file in Files.All where file.Connected select file).Count();

            if (Settings.Default.MaxDownloads > 0 && currentDownloadCount >= Settings.Default.MaxDownloads)
            {
                _log.Error("BotConnect(" + aEventArgs.Value1 + ") skipping, because already " + Settings.Default.MaxDownloads + " packets are downloading");

                IrcConnection connection = _connections.SingleOrDefault(c => c.Server == aEventArgs.Value1.Parent.Parent.Parent);
                if (connection != null)
                {
                    connection.AddBotToQueue(aEventArgs.Value1.Parent, Settings.Default.BotWaitTime);
                }
                return;
            }

            var download = _botDownloads.SingleOrDefault(c => c.Packet == aEventArgs.Value1);

            if (download == null)
            {
                download = new BotDownload
                {
                    Files     = Files,
                    Packet    = aEventArgs.Value1,
                    StartSize = aEventArgs.Value2,
                    IP        = aEventArgs.Value3,
                    Port      = aEventArgs.Value4,
                    MaxData   = aEventArgs.Value1.RealSize - aEventArgs.Value2,
                    Scheduler = Scheduler
                };

                download.OnDisconnected      += BotDisconnected;
                download.OnNotificationAdded += AddNotification;

                _botDownloads.Add(download);
                download.Start(aEventArgs.Value3 + ":" + aEventArgs.Value4);
            }
            else
            {
                // uhh - that should not happen
                _log.Error("BotConnect(" + aEventArgs.Value1 + ") is already downloading");
            }
        }
Esempio n. 2
0
        void BotConnect(object aSender, EventArgs<Packet, Int64, IPAddress, int> aEventArgs)
        {
            var download = _botDownloads.SingleOrDefault(c => c.Packet == aEventArgs.Value1);
            if (download == null)
            {
                download = new BotDownload
                {
                    Files = Files,
                    Packet = aEventArgs.Value1,
                    StartSize = aEventArgs.Value2,
                    IP = aEventArgs.Value3,
                    Port = aEventArgs.Value4,
                    MaxData = aEventArgs.Value1.RealSize - aEventArgs.Value2,
                    Scheduler = Scheduler
                };

                download.OnDisconnected += BotDisconnected;
                download.OnNotificationAdded += AddNotification;

                _botDownloads.Add(download);
                download.Start(aEventArgs.Value3 + ":" + aEventArgs.Value4);
            }
            else
            {
                // uhh - that should not happen
                _log.Error("BotConnect(" + aEventArgs.Value1 + ") is already downloading");
            }
        }
Esempio n. 3
0
        void BotConnect(object aSender, EventArgs<Packet, Int64, IPAddress, int> aEventArgs)
        {
            int currentDownloadCount = (from file in Files.All where file.Connected select file).Count();
            if (Settings.Default.MaxDownloads > 0 && currentDownloadCount >= Settings.Default.MaxDownloads)
            {
                _log.Error("BotConnect(" + aEventArgs.Value1 + ") skipping, because already " + Settings.Default.MaxDownloads + " packets are downloading");

                IrcConnection connection = _connections.SingleOrDefault(c => c.Server == aEventArgs.Value1.Parent.Parent.Parent);
                if (connection != null)
                {
                    connection.AddBotToQueue(aEventArgs.Value1.Parent, Settings.Default.BotWaitTime);
                }
                return;
            }

            var download = _botDownloads.SingleOrDefault(c => c.Packet == aEventArgs.Value1);
            if (download == null)
            {
                download = new BotDownload
                {
                    Files = Files,
                    Packet = aEventArgs.Value1,
                    StartSize = aEventArgs.Value2,
                    IP = aEventArgs.Value3,
                    Port = aEventArgs.Value4,
                    MaxData = aEventArgs.Value1.RealSize - aEventArgs.Value2,
                    Scheduler = Scheduler
                };

                download.OnDisconnected += BotDisconnected;
                download.OnNotificationAdded += AddNotification;

                _botDownloads.Add(download);
                download.Start(aEventArgs.Value3 + ":" + aEventArgs.Value4);
            }
            else
            {
                // uhh - that should not happen
                _log.Error("BotConnect(" + aEventArgs.Value1 + ") is already downloading");
            }
        }