/// <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); } } }
/// <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); } } }
/// <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); } } } }
/// <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); } } } } }
/// <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); } }