net.i2p.client.streaming

## Class ConnectionManager

- java.lang.Object
- - net.i2p.client.streaming.ConnectionManager

-      class ConnectionManager
      extends Object

  Coordinate all of the connections for a single local destination.

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static interface` | `ConnectionManager.PingNotifier`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ConnectionManager(I2PAppContext context, I2PSession session, int maxConcurrent, ConnectionOptions defaultOptions)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `answerPings()` do we respond to pings that aren't on an existing connection?
    `Connection` | `connect(Destination peer, ConnectionOptions opts)` Build a new connection to the given peer.
    `void` | `disconnectAllHard()` Something b0rked hard, so kill all of our connections without mercy.
    `boolean` | `getAllowIncomingConnections()`
    `(package private) Connection` | `getConnectionByInboundId(long id)`
    `(package private) Connection` | `getConnectionByOutboundId(long id)` not guaranteed to be unique, but in case we receive more than one packet on an inbound connection that we havent ack'ed yet...
    `ConnectionHandler` | `getConnectionHandler()`
    `MessageHandler` | `getMessageHandler()`
    `PacketHandler` | `getPacketHandler()`
    `PacketQueue` | `getPacketQueue()`
    `I2PSession` | `getSession()`
    `long` | `getSoTimeout()` Get the socket accept() timeout.
    `Set<Connection>` | `listConnections()` return a set of Connection objects
    `boolean` | `ping(Destination peer, long timeoutMs)` blocking
    `boolean` | `ping(Destination peer, long timeoutMs, boolean blocking)`
    `boolean` | `ping(Destination peer, long timeoutMs, boolean blocking, ConnectionManager.PingNotifier notifier)`
    `boolean` | `ping(Destination peer, long timeoutMs, boolean blocking, SessionKey keyToUse, Set tagsToSend, ConnectionManager.PingNotifier notifier)` Deprecated. I2PSession ignores tags, use non-tag variant
    `Connection` | `receiveConnection(Packet synPacket)` Create a new connection based on the SYN packet we received.
    `(package private) void` | `receivePong(long pingId)`
    `void` | `removeConnection(Connection con)` Drop the (already closed) connection on the floor.
    `void` | `setAllowIncomingConnections(boolean allow)`
    `void` | `setSoTimeout(long x)` Set the socket accept() timeout.
    `void` | `updateOptsFromShare(Connection con)`
    `void` | `updateShareOpts(Connection con)`

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

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

- - ### Constructor Detail

    - #### ConnectionManager

          public ConnectionManager(I2PAppContext context,
                           I2PSession session,
                           int maxConcurrent,
                           ConnectionOptions defaultOptions)

  - ### Method Detail

    - #### getConnectionByInboundId

          Connection getConnectionByInboundId(long id)

    - #### getConnectionByOutboundId

          Connection getConnectionByOutboundId(long id)

      not guaranteed to be unique, but in case we receive more than one packet on an inbound connection that we havent ack'ed yet...

    - #### setSoTimeout

          public void setSoTimeout(long x)

      Set the socket accept() timeout.
      Parameters:
        `x` -

    - #### getSoTimeout

          public long getSoTimeout()

      Get the socket accept() timeout.
      Returns:
        accept timeout in ms.

    - #### setAllowIncomingConnections

          public void setAllowIncomingConnections(boolean allow)

    - #### getAllowIncomingConnections

          public boolean getAllowIncomingConnections()

      Returns:
        if we should accept connections

    - #### receiveConnection

          public Connection receiveConnection(Packet synPacket)

      Create a new connection based on the SYN packet we received.
      Parameters:
        `synPacket` - SYN packet to process
      Returns:
        created Connection with the packet's data already delivered to it, or null if the syn's streamId was already taken

    - #### connect

          public Connection connect(Destination peer,
                           ConnectionOptions opts)

      Build a new connection to the given peer. This blocks if there is no connection delay, otherwise it returns immediately.
      Parameters:
        `peer` - Destination to contact
        `opts` - Connection's options
      Returns:
        new connection, or null if we have exceeded our limit

    - #### getMessageHandler

          public MessageHandler getMessageHandler()

    - #### getPacketHandler

          public PacketHandler getPacketHandler()

    - #### getSession

          public I2PSession getSession()

    - #### updateOptsFromShare

          public void updateOptsFromShare(Connection con)

    - #### updateShareOpts

          public void updateShareOpts(Connection con)

    - #### getConnectionHandler

          public ConnectionHandler getConnectionHandler()

    - #### getPacketQueue

          public PacketQueue getPacketQueue()

    - #### answerPings

          public boolean answerPings()

      do we respond to pings that aren't on an existing connection?

    - #### disconnectAllHard

          public void disconnectAllHard()

      Something b0rked hard, so kill all of our connections without mercy. Don't bother sending close packets.

    - #### removeConnection

          public void removeConnection(Connection con)

      Drop the (already closed) connection on the floor.
      Parameters:
        `con` - Connection to drop.

    - #### listConnections

          public Set<Connection> listConnections()

      return a set of Connection objects
      Returns:
        set of Connection objects

    - #### ping

          public boolean ping(Destination peer,
                     long timeoutMs)

      blocking

    - #### ping

          public boolean ping(Destination peer,
                     long timeoutMs,
                     boolean blocking)

    - #### ping

          public boolean ping(Destination peer,
                     long timeoutMs,
                     boolean blocking,
                     SessionKey keyToUse,
                     Set tagsToSend,
                     ConnectionManager.PingNotifier notifier)

      Deprecated. I2PSession ignores tags, use non-tag variant
      Parameters:
        `keyToUse` - ignored
        `tagsToSend` - ignored

    - #### ping

          public boolean ping(Destination peer,
                     long timeoutMs,
                     boolean blocking,
                     ConnectionManager.PingNotifier notifier)

    - #### receivePong

          void receivePong(long pingId)