net.i2p.i2ptunnel.irc

## Class DCCClientManager

- java.lang.Object
- - net.i2p.i2ptunnel.irc.EventReceiver
  - - net.i2p.i2ptunnel.irc.DCCClientManager

- All Implemented Interfaces:
    EventDispatcher

      public class DCCClientManager
      extends EventReceiver

  Start, track, and expire the I2PTunnelDCCClients.

                                                  direct conn
                      <---> I2PTunnelDCCServer <--------------->I2PTunnelDCCClient <---->
         originating                                                                     responding
         chat client                                                                     chat client
              CHAT    ---> I2PTunnelIRCClient --> IRC server --> I2TunnelIRCClient ----->
              SEND    ---> I2PTunnelIRCClient --> IRC server --> I2TunnelIRCClient ----->
              RESUME  <--- I2PTunnelIRCClient <-- IRC server <-- I2TunnelIRCClient <-----
              ACCEPT  ---> I2PTunnelIRCClient --> IRC server --> I2TunnelIRCClient ----->

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `DCCClientManager(I2PSocketManager sktMgr, Logging logging, EventDispatcher dispatch, I2PTunnel tunnel)` Create a new manager for DCC client tunnels.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `int` | `acceptIncoming(int port)` Handle an incoming DCC ACCEPT response from the remote peer.
    `boolean` | `close(boolean forced)` Close all DCC client tunnels managed by this manager.
    `int` | `newIncoming(String b32, int port, String type)` Handle an incoming DCC request from a remote peer.
    `void` | `notifyEvent(String eventName, Object args)` EventReceiver callback for DCC client connection events.
    `int` | `resumeOutgoing(int port)` Handle an outgoing DCC RESUME request.

    - ### Methods inherited from class net.i2p.i2ptunnel.irc.EventReceiver

      `attachEventDispatcher, detachEventDispatcher, getEventDispatcher, getEvents, getEventValue, ignoreEvents, unIgnoreEvents, waitEventValue`

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

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

- - ### Constructor Detail

    - #### DCCClientManager

          public DCCClientManager(I2PSocketManager sktMgr,
                                  Logging logging,
                                  EventDispatcher dispatch,
                                  I2PTunnel tunnel)

      Create a new manager for DCC client tunnels.
      Parameters:
        `sktMgr` - the socket manager for creating connections
        `logging` - the logging facility
        `dispatch` - the event dispatcher for tunnel events
        `tunnel` - the parent I2PTunnel instance

  - ### Method Detail

    - #### acceptIncoming

          public int acceptIncoming(int port)

      Handle an incoming DCC ACCEPT response from the remote peer. Searches for a matching tunnel in complete, active, or incoming states and creates a new incoming connection with the original parameters.
      Parameters:
        `port` - the remote DCC server's I2P port from the ACCEPT message
      Returns:
        the local DCC client tunnel port for the new connection, or -1 if no match found

    - #### close

          public boolean close(boolean forced)

      Close all DCC client tunnels managed by this manager. Stops all incoming, active, and complete client tunnels and clears the internal maps.
      Parameters:
        `forced` - unused parameter, retained for compatibility
      Returns:
        true always, indicating all tunnels were closed

    - #### newIncoming

          public int newIncoming(String b32,
                                 int port,
                                 String type)

      Handle an incoming DCC request from a remote peer. Validates the base32 address and creates a new DCC client tunnel.
      Parameters:
        `b32` - the remote DCC server's base32 destination (60 chars, ending in .b32.i2p)
        `port` - the remote DCC server's I2P port
        `type` - the DCC type (currently ignored)
      Returns:
        the local DCC client tunnel port, or -1 on error (invalid address or too many connections)

    - #### notifyEvent

          public void notifyEvent(String eventName,
                                  Object args)

      EventReceiver callback for DCC client connection events. Handles connection start and stop events to update tunnel state.
      Specified by:
        `notifyEvent` in interface `EventDispatcher`
      Specified by:
        `notifyEvent` in class `EventReceiver`
      Parameters:
        `eventName` - the event name (CONNECT_START_EVENT or CONNECT_STOP_EVENT)
        `args` - the event arguments (I2PTunnelDCCClient for start, Integer port for stop)

    - #### resumeOutgoing

          public int resumeOutgoing(int port)

      Handle an outgoing DCC RESUME request. Stops the existing client tunnel for the given local port.
      Parameters:
        `port` - the local DCC client tunnel port to resume
      Returns:
        the local port of the stopped tunnel, or -1 if no matching tunnel was found