/// <summary> /// 取消发送文件事件方法 /// </summary> /// <param name="md5"></param> /// <param name="remoteIP"></param> private void OnRequestCancelSendFile(string md5, IPEndPoint remoteIP) { ReceiveFileManager receiveFileManager; if (ReceiveFileManagerList.TryGetValue( md5, out receiveFileManager)) { OnFileReceiveCancel( new FileReceiveEventArgs(receiveFileManager)); lock (_receivesyncLock) { ReceiveFileManagerList.Remove(md5); receiveFileManager.Dispose(); receiveFileManager = null; } } else { FileReceiveEventArgs fe = new FileReceiveEventArgs(); fe.Tag = md5; OnFileReceiveCancel(fe); } Send( (int)Command.ResponeCancelSendFile, "OK", remoteIP); }
/// <summary> /// 完成接收文件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void ReceiveFileManagerReceiveFileComplete( object sender, FileReceiveCompleteEventArgs e) { ReceiveFileManager receiveFileManager = sender as ReceiveFileManager; OnFileReceiveComplete(new FileReceiveEventArgs(receiveFileManager)); ReceiveFileManagerList.Remove(receiveFileManager.MD5); }
/// <summary> /// 取消接收 /// </summary> /// <param name="md5"></param> /// <param name="remoteIP"></param> public void CancelReceive(string md5, IPEndPoint remoteIP) { ReceiveFileManager receiveFileManager; if (ReceiveFileManagerList.TryGetValue( md5, out receiveFileManager)) { Send( (int)Command.RequestCancelReceiveFile, md5, remoteIP); lock (_receivesyncLock) { ReceiveFileManagerList.Remove(md5); receiveFileManager.Dispose(); receiveFileManager = null; } } }