use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.
the class PieceItem method refresh.
@Override
public void refresh(TableCell cell) {
PEPeer peer = (PEPeer) cell.getDataSource();
int value = (peer == null) ? 0 : peer.getLastPiece();
if (!cell.setSortValue(value) && cell.isValid())
return;
cell.setText("" + value);
}
use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.
the class UpDownRatioItem method refresh.
@Override
public void refresh(TableCell cell) {
PEPeer peer = (PEPeer) cell.getDataSource();
float value = 0;
long lDivisor = 0;
long lDivident = 0;
if (peer != null) {
lDivisor = peer.getStats().getTotalDataBytesReceived() - peer.getStats().getTotalBytesDiscarded();
lDivident = peer.getStats().getTotalDataBytesSent();
// skip if divisor is small (most likely handshake) or 0 (DivisionByZero)
if (lDivisor > 1024) {
value = lDivident / (float) lDivisor;
if (value == 0)
value = -1;
} else if (lDivident > 0)
value = Float.MAX_VALUE;
}
if (!cell.setSortValue((long) (value * 1000.0d)) && cell.isValid())
return;
String s;
if (lDivisor <= 0)
s = "";
else if (value == Float.MAX_VALUE)
s = Constants.INFINITY_STRING + ":1";
else if (value == -1)
s = "1:" + Constants.INFINITY_STRING;
else
s = DisplayFormatters.formatDecimal(value, 2) + ":1";
cell.setText(s);
}
use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.
the class UpItem method refresh.
@Override
public void refresh(TableCell cell) {
PEPeer peer = (PEPeer) cell.getDataSource();
long data_value = 0;
long prot_value = 0;
if (peer != null) {
data_value = peer.getStats().getTotalDataBytesSent();
prot_value = peer.getStats().getTotalProtocolBytesSent();
}
long sort_value;
if (separate_prot_data_stats) {
sort_value = (data_value << 24) + prot_value;
} else if (data_stats_only) {
sort_value = data_value;
} else {
sort_value = data_value + prot_value;
}
if (!cell.setSortValue(sort_value) && cell.isValid())
return;
cell.setText(DisplayFormatters.formatDataProtByteCountToKiBEtc(data_value, prot_value));
}
use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.
the class UpSpeedLimitItem method refresh.
@Override
public void refresh(TableCell cell) {
PEPeer peer = (PEPeer) cell.getDataSource();
long value = (peer == null) ? 0 : peer.getUploadRateLimitBytesPerSecond();
if (!cell.setSortValue(value) && cell.isValid())
return;
if (value == -1) {
cell.setText(MessageText.getString("MyTorrents.items.UpSpeedLimit.disabled"));
} else if (value == 0) {
cell.setText(Constants.INFINITY_STRING);
} else {
cell.setText(DisplayFormatters.formatByteCountToKiBEtcPerSec(value));
}
}
use of com.biglybt.core.peer.PEPeer in project BiglyBT by BiglySoftware.
the class DownloadManagerImpl method addPeerListener.
@Override
public void addPeerListener(DownloadManagerPeerListener listener, boolean bDispatchForExisting) {
try {
peer_listeners_mon.enter();
peer_listeners.addListener(listener);
if (!bDispatchForExisting) {
// finally will call
return;
}
for (PEPeer peer : current_peers.keySet()) {
peer_listeners.dispatch(listener, LDT_PE_PEER_ADDED, peer);
}
PEPeerManager temp = controller.getPeerManager();
if (temp != null) {
peer_listeners.dispatch(listener, LDT_PE_PM_ADDED, temp);
}
} finally {
peer_listeners_mon.exit();
}
}
Aggregations