java.lang.Object
net.i2p.i2ptunnel.irc.EventReceiver
net.i2p.i2ptunnel.irc.DCCClientManager
- All Implemented Interfaces:
EventDispatcher
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
ConstructorsConstructorDescriptionDCCClientManager(I2PSocketManager sktMgr, Logging logging, EventDispatcher dispatch, I2PTunnel tunnel) Create a new manager for DCC client tunnels.Method Summary
All MethodsModifier and TypeMethodDescriptionintacceptIncoming(int port) Handle an incoming DCC ACCEPT response from the remote peer.booleanclose(boolean forced) Close all DCC client tunnels managed by this manager.intnewIncoming(String b32, int port, String type) Handle an incoming DCC request from a remote peer.voidnotifyEvent(String eventName, Object args) EventReceiver callback for DCC client connection events.intresumeOutgoing(int port) Handle an outgoing DCC RESUME request.Methods inherited from class EventReceiver
attachEventDispatcher, detachEventDispatcher, getEventDispatcher, getEvents, getEventValue, ignoreEvents, unIgnoreEvents, waitEventValueModifier and TypeMethodDescriptionvoidSubscribe to IRC events.voidUnsubscribe from IRC events.Object to be used to deliver events (usuallythis, but YMMV).All registered event names.getEventValue(String name) Value of the last fired event.voidStop waiting for events.voidAlmost like the method above :-).waitEventValue(String name) Block until the event fires and return its value.
Constructor Details
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 connectionslogging- the logging facilitydispatch- the event dispatcher for tunnel eventstunnel- the parent I2PTunnel instance
Method Details
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
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 porttype- the DCC type (currently ignored)- Returns:
- the local DCC client tunnel port, or -1 on error (invalid address or too many connections)
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
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
notifyEvent
EventReceiver callback for DCC client connection events. Handles connection start and stop events to update tunnel state.- Specified by:
notifyEventin interfaceEventDispatcher- Specified by:
notifyEventin classEventReceiver- Parameters:
eventName- the event name (CONNECT_START_EVENT or CONNECT_STOP_EVENT)args- the event arguments (I2PTunnelDCCClient for start, Integer port for stop)