Package net.i2p.client.streaming.impl
Class ConnectionManager
java.lang.Object
net.i2p.client.streaming.impl.ConnectionManager
Coordinate all of the connections for a single local destination.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionstatic interfaceThe callback interface for a pong.
- 
Field SummaryFields
- 
Constructor SummaryConstructorsConstructorDescriptionConnectionManager(I2PAppContext context, I2PSession session, ConnectionOptions defaultOptions, IncomingConnectionFilter connectionFilter) Manage all conns for this session
- 
Method SummaryModifier and TypeMethodDescriptionbooleando we respond to pings that aren't on an existing connection?connect(Destination peer, ConnectionOptions opts, I2PSession session) Build a new connection to the given peer.voidSomething b0rked hard, so kill all of our connections without mercy.boolean(package private) ConnectiongetConnectionByInboundId(long id) (package private) ConnectiongetConnectionByOutboundId(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...This is the primary session onlylongGet the socket accept() timeout.return a set of Connection objectsbooleanping(Destination peer, int fromPort, int toPort, long timeoutMs) blockingbooleanping(Destination peer, int fromPort, int toPort, long timeoutMs, boolean blocking) booleanping(Destination peer, int fromPort, int toPort, long timeoutMs, boolean blocking, ConnectionManager.PingNotifier notifier) byte[]ping(Destination peer, int fromPort, int toPort, long timeoutMs, byte[] payload) blockingbooleanping(Destination peer, long timeoutMs) blockingreceiveConnection(Packet synPacket) Create a new connection based on the SYN packet we received.booleanreceivePing(Connection con, Packet ping) Process a ping by checking for throttling, etc., then sending a pong.(package private) voidreceivePong(long pingId, ByteArray payload) voidDrop the (already closed) connection on the floor.voidsetAllowIncomingConnections(boolean allow) voidsetSoTimeout(long x) Set the socket accept() timeout.voidshutdown()Kill all connections and the timers.toString()voidvoidvoidbooleanwasRecentlyClosed(long inboundID) Was this conn recently closed?
- 
Field Details- 
PROP_BLACKLIST- Since:
- 0.9.3
- See Also:
 
 
- 
- 
Constructor Details- 
ConnectionManagerpublic ConnectionManager(I2PAppContext context, I2PSession session, ConnectionOptions defaultOptions, IncomingConnectionFilter connectionFilter) Manage all conns for this session
 
- 
- 
Method Details- 
getConnectionByInboundId
- 
getConnectionByOutboundIdnot guaranteed to be unique, but in case we receive more than one packet on an inbound connection that we havent ack'ed yet...
- 
wasRecentlyClosedpublic boolean wasRecentlyClosed(long inboundID) Was this conn recently closed?- Since:
- 0.9.12
 
- 
setSoTimeoutpublic void setSoTimeout(long x) Set the socket accept() timeout.- Parameters:
- x-
 
- 
getSoTimeoutpublic long getSoTimeout()Get the socket accept() timeout.- Returns:
- accept timeout in ms.
 
- 
setAllowIncomingConnectionspublic void setAllowIncomingConnections(boolean allow) 
- 
updateOptionspublic void updateOptions()
- 
getAllowIncomingConnectionspublic boolean getAllowIncomingConnections()- Returns:
- if we should accept connections
 
- 
receiveConnectionCreate 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, or if the connection was rejected
 
- 
receivePingProcess a ping by checking for throttling, etc., then sending a pong.- Parameters:
- con- null if unknown
- ping- Ping packet to process, must have From and Sig fields, with signature already verified, only if answerPings() returned true
- Returns:
- true if we sent a pong
- Since:
- 0.9.12 from PacketHandler.receivePing()
 
- 
connectBuild a new connection to the given peer. This blocks if there is no connection delay, otherwise it returns immediately.- Parameters:
- peer- Destination to contact, non-null
- opts- Connection's options
- session- generally the session from the constructor, but could be a subsession
- Returns:
- new connection, or null if we have exceeded our limit
 
- 
getMessageHandler
- 
getPacketHandler
- 
getSessionThis is the primary session only
- 
getConnectionHandler
- 
getPacketQueue
- 
answerPingspublic boolean answerPings()do we respond to pings that aren't on an existing connection?
- 
disconnectAllHardpublic void disconnectAllHard()Something b0rked hard, so kill all of our connections without mercy. Don't bother sending close packets. This will not close the ServerSocket. This will not kill the timer threads. CAN continue to use the manager.
- 
shutdownpublic void shutdown()Kill all connections and the timers. Don't bother sending close packets. As of 0.9.17, this will close the ServerSocket, killing one thread in accept(). CANNOT continue to use the manager or restart.- Since:
- 0.9.7
 
- 
removeConnectionDrop the (already closed) connection on the floor.- Parameters:
- con- Connection to drop.
 
- 
listConnectionsreturn a set of Connection objects- Returns:
- set of Connection objects
 
- 
pingblocking- Parameters:
- timeoutMs- greater than zero
- Returns:
- true if pong received
 
- 
pingblocking- Parameters:
- timeoutMs- greater than zero
- Returns:
- true if pong received
- Since:
- 0.9.12 added port args
 
- 
ping- Parameters:
- timeoutMs- greater than zero
- Returns:
- true if blocking and pong received
- Since:
- 0.9.12 added port args
 
- 
pingpublic boolean ping(Destination peer, int fromPort, int toPort, long timeoutMs, boolean blocking, ConnectionManager.PingNotifier notifier) - Parameters:
- timeoutMs- greater than zero
- notifier- may be null
- Returns:
- true if blocking and pong received
- Since:
- 0.9.12 added port args
 
- 
pingblocking- Parameters:
- timeoutMs- greater than zero
- payload- non-null, include in packet, up to 32 bytes may be returned in pong not copied, do not modify
- Returns:
- the payload received in the pong, zero-length if none, null on failure or timeout
- Since:
- 0.9.18
 
- 
receivePong- Parameters:
- payload- may be null
 
- 
toString
 
-