org.klomp.snark

## Class ExtensionHandler

- java.lang.Object
- - org.klomp.snark.ExtensionHandler

-     abstract class ExtensionHandler
      extends Object

  REF: BEP 10 Extension Protocol

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `ID_COMMENT`
    `static int` | `ID_DHT`
    `static int` | `ID_HANDSHAKE`
    `static int` | `ID_METADATA`
    `static int` | `ID_PEX`
    `static String` | `TYPE_COMMENT`
    `static String` | `TYPE_DHT` not using the option bit since the compact format is different
    `static String` | `TYPE_METADATA`
    `static String` | `TYPE_PEX` not ut_pex since the compact format is different

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ExtensionHandler()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static byte[]` | `getHandshake(int metasize, boolean pexAndMetadata, boolean dht, boolean uploadOnly, boolean comment)`
    `static void` | `handleMessage(Peer peer, PeerListener listener, int id, byte[] bs)`
    `static void` | `locked_sendComments(Peer peer, int num, CommentSet comments)` Send comments Caller must sync on comments
    `static void` | `sendCommentReq(Peer peer, int num)` Send comment request
    `static void` | `sendDHT(Peer peer, int qport, int rport)` Send the DHT port numbers
    `static void` | `sendPEX(Peer peer, List<Peer> pList)` added.f and dropped unsupported

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### ID_COMMENT

          public static final int ID_COMMENT

      See Also:
        Constant Field Values

    - #### ID_DHT

          public static final int ID_DHT

      See Also:
        Constant Field Values

    - #### ID_HANDSHAKE

          public static final int ID_HANDSHAKE

      See Also:
        Constant Field Values

    - #### ID_METADATA

          public static final int ID_METADATA

      See Also:
        Constant Field Values

    - #### ID_PEX

          public static final int ID_PEX

      See Also:
        Constant Field Values

    - #### TYPE_COMMENT

          public static final String TYPE_COMMENT

      See Also:
        Constant Field Values

    - #### TYPE_DHT

          public static final String TYPE_DHT

      not using the option bit since the compact format is different
      See Also:
        Constant Field Values

    - #### TYPE_METADATA

          public static final String TYPE_METADATA

      See Also:
        Constant Field Values

    - #### TYPE_PEX

          public static final String TYPE_PEX

      not ut_pex since the compact format is different
      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### ExtensionHandler

          ExtensionHandler()

  - ### Method Detail

    - #### getHandshake

          public static byte[] getHandshake(int metasize,
                                            boolean pexAndMetadata,
                                            boolean dht,
                                            boolean uploadOnly,
                                            boolean comment)

      Parameters:
        `metasize` - -1 if unknown
        `pexAndMetadata` - advertise these capabilities
        `dht` - advertise DHT capability
        `comment` - advertise ut_comment capability
      Returns:
        bencoded outgoing handshake message

    - #### handleMessage

          public static void handleMessage(Peer peer,
                                           PeerListener listener,
                                           int id,
                                           byte[] bs)

    - #### locked_sendComments

          public static void locked_sendComments(Peer peer,
                                                 int num,
                                                 CommentSet comments)

      Send comments Caller must sync on comments
      Parameters:
        `num` - max to send
        `comments` - non-null

    - #### sendCommentReq

          public static void sendCommentReq(Peer peer,
                                            int num)

      Send comment request

    - #### sendDHT

          public static void sendDHT(Peer peer,
                                     int qport,
                                     int rport)

      Send the DHT port numbers

    - #### sendPEX

          public static void sendPEX(Peer peer,
                                     List<Peer> pList)

      added.f and dropped unsupported
      Parameters:
        `pList` - non-null