コード例 #1
0
ファイル: XferModule.cs プロジェクト: BogusCurry/opensim-1
        public void transfersTimeTick(int now)
        {
            XferDownLoad[] xfrs;
            lock (Transfers)
            {
                if (Transfers.Count == 0)
                {
                    return;
                }

                xfrs = new XferDownLoad[Transfers.Count];
                Transfers.Values.CopyTo(xfrs, 0);
            }

            foreach (XferDownLoad xfr in xfrs)
            {
                if (xfr.checkTime(now))
                {
                    ulong xfrID = xfr.XferID;
                    lock (Transfers)
                    {
                        if (Transfers.ContainsKey(xfrID))
                        {
                            Transfers.Remove(xfrID);
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: XferModule.cs プロジェクト: BogusCurry/opensim-1
        /// <summary>
        ///
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="xferID"></param>
        /// <param name="fileName"></param>
        public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
        {
            lock (NewFiles)
            {
                if (NewFiles.ContainsKey(fileName))
                {
                    lock (Transfers)
                    {
                        if (!Transfers.ContainsKey(xferID))
                        {
                            byte[] fileData  = NewFiles[fileName].Data;
                            int    burstSize = remoteClient.GetAgentThrottleSilent((int)ThrottleOutPacketType.Task) >> 10;
                            burstSize  *= remoteClient.PingTimeMS;
                            burstSize >>= 10; //  ping is ms, 1 round trip
                            if (burstSize > 32)
                            {
                                burstSize = 32;
                            }
                            XferDownLoad transaction =
                                new XferDownLoad(fileName, fileData, xferID, remoteClient, burstSize);

                            Transfers.Add(xferID, transaction);
                            transaction.StartSend();

                            // The transaction for this file is on its way
                            RemoveOrDecrementFile(fileName);
                        }
                    }
                }
                else
                {
                    m_log.WarnFormat("[Xfer]: {0} not found", fileName);
                }
            }
        }
コード例 #3
0
        /// <summary>
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="xferID"></param>
        /// <param name="fileName"></param>
        public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
        {
            lock (NewFiles)
            {
                if (NewFiles.ContainsKey(fileName))
                {
                    if (!Transfers.ContainsKey(xferID))
                    {
                        byte[]       fileData    = NewFiles[fileName].Data;
                        XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);

                        Transfers.Add(xferID, transaction);

                        if (transaction.StartSend())
                        {
                            RemoveXferData(xferID);
                        }

                        // The transaction for this file is either complete or on its way
                        RemoveOrDecrement(fileName);
                    }
                }
                else
                {
                    MainConsole.Instance.WarnFormat("[Xfer]: {0} not found", fileName);
                }
            }
        }
コード例 #4
0
 private void RemoveXferData(ulong xferID)
 {
     // NewFiles must be locked!
     if (Transfers.ContainsKey(xferID))
     {
         XferDownLoad xferItem = Transfers[xferID];
         Transfers.Remove(xferID);
         xferItem.Data        = new byte[0]; // Clear the data
         xferItem.DataPointer = 0;
     }
 }
コード例 #5
0
 public void AckPacket(IClientAPI remoteClient, ulong xferID, uint packet)
 {
     lock (NewFiles) // This is actually to lock Transfers
     {
         if (Transfers.ContainsKey(xferID))
         {
             XferDownLoad dl = Transfers[xferID];
             if (Transfers[xferID].AckPacket(packet))
             {
                 RemoveXferData(xferID);
                 RemoveOrDecrement(dl.FileName);
             }
         }
     }
 }
コード例 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="xferID"></param>
        /// <param name="fileName"></param>
        public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
        {
            lock (NewFiles)
            {
                if (NewFiles.ContainsKey(fileName))
                {
                    if (!Transfers.ContainsKey(xferID))
                    {
                        byte[]       fileData    = NewFiles[fileName];
                        XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);

                        Transfers.Add(xferID, transaction);
                        NewFiles.Remove(fileName);

                        if (transaction.StartSend())
                        {
                            Transfers.Remove(xferID);
                        }
                    }
                }
                else
                {
                    if (RequestTime.Count > 0)
                    {
                        TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks);
                        if (ts.TotalSeconds > 30)
                        {
                            Requests.Remove(RequestTime[0].fileName);
                            RequestTime.RemoveAt(0);
                        }
                    }

                    if (!Requests.ContainsKey(fileName))
                    {
                        XferRequest nRequest = new XferRequest();
                        nRequest.remoteClient = remoteClient;
                        nRequest.xferID       = xferID;
                        nRequest.fileName     = fileName;
                        nRequest.timeStamp    = DateTime.UtcNow;
                        Requests.Add(fileName, nRequest);
                        RequestTime.Add(nRequest);
                    }
                }
            }
        }
コード例 #7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="xferID"></param>
        /// <param name="fileName"></param>
        public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
        {
            lock (NewFiles)
            {
                if (NewFiles.ContainsKey(fileName))
                {
                    if (!Transfers.ContainsKey(xferID))
                    {
                        byte[]       fileData    = NewFiles[fileName];
                        XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);
                        Transfers.Add(xferID, transaction);
                        NewFiles.Remove(fileName);

                        if (transaction.StartSend())
                        {
                            Transfers.Remove(xferID);
                        }
                    }
                }
            }
        }
コード例 #8
0
ファイル: XferModule.cs プロジェクト: NickyPerian/Aurora
        /// <summary>
        ///
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="xferID"></param>
        /// <param name="fileName"></param>
        public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
        {
            lock (NewFiles)
            {
                if (NewFiles.ContainsKey(fileName))
                {
                    if (!Transfers.ContainsKey(xferID))
                    {
                        byte[] fileData = NewFiles[fileName];
                        XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);

                        Transfers.Add(xferID, transaction);
                        NewFiles.Remove(fileName);

                        if (transaction.StartSend())
                        {
                            Transfers.Remove(xferID);
                        }
                    }
                }
                else
                {
                    if (RequestTime.Count > 0)
                    {
                        TimeSpan ts = new TimeSpan(DateTime.UtcNow.Ticks - RequestTime[0].timeStamp.Ticks);
                        if (ts.TotalSeconds > 30)
                        {
                            Requests.Remove(RequestTime[0].fileName);
                            RequestTime.RemoveAt(0);
                        }
                    }

                    if (!Requests.ContainsKey(fileName))
                    {
                        XferRequest nRequest = new XferRequest();
                        nRequest.remoteClient = remoteClient;
                        nRequest.xferID = xferID;
                        nRequest.fileName = fileName;
                        nRequest.timeStamp = DateTime.UtcNow;
                        Requests.Add(fileName, nRequest);
                        RequestTime.Add(nRequest);
                    }
                    
                }
            }
        }
コード例 #9
0
ファイル: XferModule.cs プロジェクト: RadaSangOn/workCore2
        /// <summary>
        ///
        /// </summary>
        /// <param name="remoteClient"></param>
        /// <param name="xferID"></param>
        /// <param name="fileName"></param>
        public void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
        {
            lock (NewFiles)
            {
                if (NewFiles.ContainsKey(fileName))
                {
                    if (!Transfers.ContainsKey(xferID))
                    {
                        byte[] fileData = NewFiles[fileName].Data;
                        XferDownLoad transaction = new XferDownLoad(fileName, fileData, xferID, remoteClient);

                        Transfers.Add(xferID, transaction);

                        if (transaction.StartSend())
                            RemoveXferData(xferID);

                        // The transaction for this file is either complete or on its way
                        RemoveOrDecrement(fileName);

                    }
                }
                else
                    m_log.WarnFormat("[Xfer]: {0} not found", fileName);
                
            }
        }