Exemplo n.º 1
0
 void BotConnected(Packet aPack, BotConnection aCon)
 {
 }
Exemplo n.º 2
0
        void BotDisconnected(Packet aPacket, BotConnection aCon)
        {
            aCon.Packet = null;
            aCon.Connection = null;

            if (_downloads.ContainsKey(aPacket))
            {
                aCon.Connected -= BotConnected;
                aCon.Disconnected -= BotDisconnected;
                _downloads.Remove(aPacket);

                try
                {
                    // if the connection never connected, there will be no part!
                    // and if we manually killed stopped the packet there will be no parent of the part
                    if (aCon.Part != null && aCon.Part.Parent != null)
                    {
                        // do this here because the bothandler sets the part state and after this we can check the file
                        FileActions.CheckFile(aCon.Part.Parent);
                    }
                }
                catch (Exception ex)
                {
                    Log.Fatal("bot_Disconnected()", ex);
                }

                try
                {
                    ServerConnection sc = _servers[aPacket.Parent.Parent.Parent];
                    sc.CreateTimer(aPacket.Parent, Settings.Instance.CommandWaitTime, false);
                }
                catch (Exception ex)
                {
                    Log.Fatal("bot_Disconnected() request", ex);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// </summary>
        /// <param name="aPack"> </param>
        /// <param name="aChunk"> </param>
        /// <param name="aIp"> </param>
        /// <param name="aPort"> </param>
        void BotConnect(Packet aPack, Int64 aChunk, IPAddress aIp, int aPort)
        {
            if (!_downloads.ContainsKey(aPack))
            {
                new Thread(() =>
                {
                    var con = new BotConnection
                    {
                        FileActions = FileActions,
                        Packet = aPack,
                        StartSize = aChunk,
                        Connection = new Connection.Connection {Hostname = aIp.ToString(), Port = aPort, MaxData = aPack.RealSize - aChunk}
                    };

                    con.Connected += BotConnected;
                    con.Disconnected += BotDisconnected;

                    _downloads.Add(aPack, con);
                    con.Connection.Connect();
                }).Start();
            }
            else
            {
                // uhh - that should not happen
                Log.Error("IrcParserAddDownload(" + aPack + ") is already downloading");
            }
        }