1 /* 2 * Created on Feb 25, 2005 3 * Created by Alon Rohter 4 * Copyright (C) Azureus Software, Inc, All Rights Reserved. 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version 2 9 * of the License, or (at your option) any later version. 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * 18 */ 19 20 package org.gudy.azureus2.core3.peer; 21 22 import com.aelitis.azureus.core.peermanager.piecepicker.util.BitFlags; 23 24 /** 25 * Listener for peer events. 26 */ 27 public interface PEPeerListener { 28 29 /** 30 * The peer has changed to the given state. 31 * @param peer the peer the message is about 32 * @param new_state of peer 33 */ stateChanged(PEPeer peer, int new_state )34 public void stateChanged(PEPeer peer, int new_state ); 35 36 /** 37 * The peer has sent us a bad piece data chunk. 38 * @param peer the peer the message is about 39 * @param piece_num piece that failed hash check 40 * @param total_bad_chunks total number of bad chunks sent by this peer so far 41 */ sentBadChunk(PEPeer peer, int piece_num, int total_bad_chunks )42 public void sentBadChunk(PEPeer peer, int piece_num, int total_bad_chunks ); 43 44 /** The peer asserts that their availability should be added to the torrent-global availability pool 45 * The peer must send when, and only when, their availability is known 46 * but not after going to CLOSING state. Upon sending this message, the peer must remember it was 47 * sent, and then later send a corresponding removeAvailability message 48 * @param peer the message is about 49 * @param peerHavePieces BitFlags of pieces availabile 50 */ addAvailability(final PEPeer peer, final BitFlags peerHavePieces)51 public void addAvailability(final PEPeer peer, final BitFlags peerHavePieces); 52 53 /** The peer asserts that their availability must now be taken from the torrent-global availability pool 54 * The peer must send this only after having sent a corresponding addAvailability message, 55 * and must not send it in a state prior to CLOSING state. The BitFlags must be complete, with all 56 * pieces from any Bitfield message as well as those from any Have messages. 57 * @param peer the message is about 58 * @param peerHavePieces BitFlags of pieces no longer available 59 */ removeAvailability(final PEPeer peer, final BitFlags peerHavePieces)60 public void removeAvailability(final PEPeer peer, final BitFlags peerHavePieces); 61 62 } 63