abstract class ExtensionHandler extends Object
| Modifier and Type | Field and Description |
|---|---|
static int | ID_COMMENT |
static int | ID_DHTDHT extension message ID (3). |
static int | ID_HANDSHAKEHandshake extension message ID (0). |
static int | ID_METADATAMetadata extension message ID (1). |
static int | ID_PEXPEX extension message ID (2). |
static String | TYPE_COMMENT |
static String | TYPE_DHTnot using the option bit since the compact format is different |
static String | TYPE_METADATAMetadata extension type string. |
static String | TYPE_PEXnot ut_pex since the compact format is different |
| Constructor and Description |
|---|
ExtensionHandler() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] | getHandshake(int metasize,
boolean pexAndMetadata,
boolean dht,
boolean uploadOnly,
boolean comment)Creates a bencoded extension handshake message. |
static void | handleMessage(Peer peer,
PeerListener listener,
int id,
byte[] bs)Handles an incoming extension message from a peer. |
static void | locked_sendComments(Peer peer,
int num,
CommentSet comments)Sends comments to a peer. |
static void | sendCommentReq(Peer peer,
int num)Sends a comment request to a peer. |
static void | sendDHT(Peer peer,
int qport,
int rport)Sends DHT port numbers to a peer. |
static void | sendPEX(Peer peer,
List<Peer> pList)Sends a PEX message with the given peer list. |
public static final int ID_COMMENT
public static final int ID_DHT
public static final int ID_HANDSHAKE
public static final int ID_METADATA
public static final int ID_PEX
public static final String TYPE_COMMENT
public static final String TYPE_DHT
public static final String TYPE_METADATA
public static final String TYPE_PEX
public static byte[] getHandshake(int metasize,
boolean pexAndMetadata,
boolean dht,
boolean uploadOnly,
boolean comment)metasize - the metadata size in bytes, or -1 if unknownpexAndMetadata - true to advertise PEX and metadata extensionsdht - true to advertise DHT capabilityuploadOnly - true to advertise upload-only mode (BEP 21)comment - true to advertise ut_comment extensionpublic static void handleMessage(Peer peer, PeerListener listener, int id, byte[] bs)
peer - the peerlistener - the peer listener for callbacksid - the extension message IDbs - the raw message bytespublic static void locked_sendComments(Peer peer, int num, CommentSet comments)
peer - the peernum - the maximum number of comments to sendcomments - non-null set of comments to sendpublic static void sendCommentReq(Peer peer, int num)
peer - the peernum - the maximum number of comments to requestpublic static void sendDHT(Peer peer, int qport, int rport)
peer - the peerqport - the query portrport - the response port