private async void HandleFinishedDownload(TransferId transferId) { await _avatarManager.ChangeFriendAvatar(transferId.FriendNumber, (_transfers[transferId]).GetMemoryStream()); RemoveTransfer(transferId); }
private void HandleFileControl(ToxFileControl fileControl, TransferId transferId) { switch (fileControl) { case ToxFileControl.Cancel: RemoveTransfer(transferId); return; } }
private void FileControlReceivedHandler(object sender, ToxEventArgs.FileControlEventArgs e) { Debug.WriteLine("File control received \t friend number: {0}, \t file number: {1}, \t control: {2}", e.FriendNumber, e.FileNumber, e.Control); var transferId = new TransferId(e.FriendNumber, e.FileNumber); if (_transfers.ContainsKey(transferId)) { HandleFileControl(e.Control, transferId); } }
public override bool Equals(object obj) { var o = obj as TransferRecordModel; if (o == null) { return(false); } return(FromAccount.Equals(o.FromAccount) && ToAccount.Equals(o.ToAccount) && Amount.Equals(o.Amount) && TransferId.Equals(o.TransferId) && Symbol.Equals(o.Symbol) && Contract.Equals(o.Contract) && CreateTime.Equals(o.CreateTime)); }
private void RemoveTransfer(TransferId transferId) { if (!_transfers.ContainsKey(transferId)) { return; } var transferToRemove = _transfers[transferId]; var direction = transferToRemove.Direction; transferToRemove.Dispose(); _transfers.Remove(transferId); Debug.WriteLine( "Avatar {0}load removed! \t friend number: {1}, \t file number: {2}, \t total avatar transfers: {3}", direction, transferId.FriendNumber, transferId.FileNumber, _transfers.Count); }
public override int GetHashCode() { int hash = 1; if (Blockchain.Length != 0) { hash ^= Blockchain.GetHashCode(); } if (Amount.Length != 0) { hash ^= Amount.GetHashCode(); } if (Interest.Length != 0) { hash ^= Interest.GetHashCode(); } if (CollateralBlockchain.Length != 0) { hash ^= CollateralBlockchain.GetHashCode(); } if (Collateral.Length != 0) { hash ^= Collateral.GetHashCode(); } if (Fee.Length != 0) { hash ^= Fee.GetHashCode(); } if (Expiration != 0UL) { hash ^= Expiration.GetHashCode(); } if (TransferId.Length != 0) { hash ^= TransferId.GetHashCode(); } if (Sighash.Length != 0) { hash ^= Sighash.GetHashCode(); } if (_unknownFields != null) { hash ^= _unknownFields.GetHashCode(); } return(hash); }
private void FileChunkReceivedHandler(object sender, ToxEventArgs.FileChunkEventArgs e) { var transferId = new TransferId(e.FriendNumber, e.FileNumber); if (IsTransferFinished(transferId)) { return; } var currentTransfer = _transfers[transferId]; currentTransfer.PutNextChunk(e); if (currentTransfer.IsFinished()) { HandleFinishedDownload(transferId); } }
private void FileChunkRequestedHandler(object sender, ToxEventArgs.FileRequestChunkEventArgs e) { var transferId = new TransferId(e.FriendNumber, e.FileNumber); if (IsTransferFinished(transferId)) { return; } var currentTransfer = _transfers[transferId]; var chunk = currentTransfer.GetNextChunk(e); var successfulChunkSend = _toxModel.FileSendChunk(e.FriendNumber, e.FileNumber, e.Position, chunk); if (successfulChunkSend) { if (currentTransfer.IsFinished()) { HandleFinishedUpload(transferId); } } }
private void HandleFinishedUpload(TransferId transferId) { RemoveTransfer(transferId); }
private bool IsTransferFinished(TransferId transferId) { return(!_transfers.ContainsKey(transferId)); }
public override int GetHashCode() { return(FromAccount.GetHashCode() + ToAccount.GetHashCode() + Amount.GetHashCode() + Symbol.GetHashCode() + TransferId.GetHashCode()); }