All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.libtorrent4j.alerts.ReadPieceAlert Maven / Gradle / Ivy

The newest version!
package org.libtorrent4j.alerts;

import org.libtorrent4j.ErrorCode;
import org.libtorrent4j.swig.read_piece_alert;
import org.libtorrent4j.TorrentHandle;

/**
 * This alert is posted when the asynchronous read operation initiated by
 * a call to {@link TorrentHandle#readPiece(int)}
 * is completed. If the read failed, the torrent
 * is paused and an error state is set and the buffer member of the alert
 * is 0. If successful, {@link #bufferPtr()} points to a buffer containing all the data
 * of the piece. {@link #piece()} is the piece index that was read. {@link #size()}
 * is the number of bytes that was read.
 * 

* If the operation fails, {@link #error()} will indicate what went wrong. * * @author gubatron * @author aldenml */ public final class ReadPieceAlert extends TorrentAlert { ReadPieceAlert(read_piece_alert alert) { super(alert); } /** * @return the error */ public ErrorCode error() { return new ErrorCode(alert.getError()); } /** * @return the native buffer pointer */ public long bufferPtr() { return alert.buffer_ptr(); } /** * @return the piece index */ public int piece() { return alert.getPiece(); } /** * @return the piece size */ public int size() { return alert.getSize(); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy