void IPayloadCallback.OnPayloadTransferUpdate(string endpointId, PayloadTransferUpdate update) { switch (update.TransferStatus) { case PayloadTransferUpdate.Status.InProgress: this.selectImage.Enabled = false; this.progress.Visibility = ViewStates.Visible; this.progress.Max = 10000; this.progress.Progress = (int)((double)update.BytesTransferred / (double)max * 10000); break; case PayloadTransferUpdate.Status.Failure: Log($"OnPayloadTransferUpdate: {endpointId} Failure - {update.TransferStatus} {update.BytesTransferred} of {update.TotalBytes}"); this.selectImage.Enabled = true; this.progress.Visibility = ViewStates.Gone; break; case PayloadTransferUpdate.Status.Success: this.selectImage.Enabled = true; this.progress.Visibility = ViewStates.Gone; Log($"OnPayloadTransferUpdate: {endpointId} Succes - {update.TransferStatus} {update.BytesTransferred} of {update.TotalBytes}"); break; } }
public override void OnPayloadTransferUpdate(string p0, PayloadTransferUpdate p1) { //Debug.WriteLine("### OnPayloadTransferUpdate " + (_mostRecentReceivedPayload?.Id == p1.PayloadId ? "RECEIVE" : "SEND") + " Id: " + p1.PayloadId + " status: " + p1.TransferStatus + " progress: " + p1.BytesTransferred + "/" + _expectedLength); if (p1.PayloadId == _mostRecentReceivedPayload?.Id) //only care about receiving { var receivingStream = _mostRecentReceivedPayload.AsStream().AsInputStream(); //TODO: dispose/close correctly - i keep doing it wrong int readBytes; switch (p1.TransferStatus) { case PayloadTransferUpdate.Status.InProgress: readBytes = receivingStream.Read(_incomingBytes, _incomingBytesCounter, _expectedLength - _incomingBytesCounter); _incomingBytesCounter += readBytes; break; case PayloadTransferUpdate.Status.Success: readBytes = receivingStream.Read(_incomingBytes, _incomingBytesCounter, _expectedLength - _incomingBytesCounter); _incomingBytesCounter += readBytes; //Debug.WriteLine("### ProcessReceivedPayload: " + _incomingBytesCounter + " of " + _expectedLength + ", Id: " + p1.PayloadId); _platformBluetooth.ProcessReceivedPayload(_incomingBytes); break; default: //failure Debug.WriteLine("### Transfer failed!"); break; } } else { if (p1.TransferStatus == PayloadTransferUpdate.Status.Success) { //Debug.WriteLine("### Closing due to sent success"); } } }
public override void OnPayloadTransferUpdate(string endpointId, PayloadTransferUpdate update) { callback.OnPayloadTransferUpdate(endpointId, update); }