package org.openslx.dozmod.filetransfer;
import org.openslx.bwlp.thrift.iface.TransferState;
import org.openslx.dozmod.util.FormatHelper;
public class TransferEvent {
/**
* Block-based progress of transfer
*/
public final byte[] progress;
/**
* Speed of transfer, human readable
*/
public final String speed;
/**
* Estimated remaining time, human readable. <code>null</code> == not
* updated
*/
public final String remaining;
/**
* Speed of transfer, in bytes per second
*/
public final long speedRaw;
/**
* Speed of transfer, human readable, including server side copying
*/
public final String virtualSpeed;
/**
* Speed of transfer, in bytes per second, including server side copying
*/
public final long virtualSpeedRaw;
/**
* Estimated remaining time, in milliseconds. 0 == not updated
*/
public final long remainingRaw;
/**
* State of the transfer
*/
public final TransferState state;
/**
* An optional error message
*/
public final String errorMessage;
/**
* How many blocks have been hashed locally
*/
public final int locallyHashedCount;
public TransferEvent(TransferState state, byte[] progress, long speedRaw, long virtualSpeedRaw, long remainingRaw,
String errorMessage, int hashCompleteCount) {
this.state = state;
this.progress = progress;
this.speedRaw = speedRaw;
this.speed = FormatHelper.bytes(speedRaw, false) + "/s";
this.virtualSpeedRaw = virtualSpeedRaw;
this.virtualSpeed = FormatHelper.bytes(virtualSpeedRaw, false) + "/s";
this.remainingRaw = remainingRaw;
if (remainingRaw == 0) {
this.remaining = null;
} else {
this.remaining = FormatHelper.formatMilliseconds(remainingRaw + 30000, false);
}
this.errorMessage = errorMessage;
this.locallyHashedCount = hashCompleteCount;
}
public TransferEvent(TransferState state, byte[] progress, long speedRaw, long virtualSpeedRaw, long remainingRaw,
String errorMessage) {
this(state, progress, speedRaw, virtualSpeedRaw, remainingRaw, errorMessage, progress == null ? 0 : progress.length);
}
}