net.i2p.client.streaming
Class I2PSocketManagerFull

java.lang.Object
  extended by net.i2p.client.streaming.I2PSocketManagerFull
All Implemented Interfaces:
I2PSocketManager

public class I2PSocketManagerFull
extends java.lang.Object
implements I2PSocketManager

Centralize the coordination and multiplexing of the local client's streaming. There should be one I2PSocketManager for each I2PSession, and if an application is sending and receiving data through the streaming library using an I2PSocketManager, it should not attempt to call I2PSession's setSessionListener or receive any messages with its .receiveMessage


Nested Class Summary
 
Nested classes/interfaces inherited from interface net.i2p.client.streaming.I2PSocketManager
I2PSocketManager.DisconnectListener
 
Field Summary
static java.lang.String PROP_MAX_STREAMS
          how many streams will we allow at once?
 
Constructor Summary
I2PSocketManagerFull()
           
I2PSocketManagerFull(I2PAppContext context, I2PSession session, java.util.Properties opts, java.lang.String name)
           
 
Method Summary
 void addDisconnectListener(I2PSocketManager.DisconnectListener lsnr)
           
 I2PSocketOptions buildOptions()
           
 I2PSocketOptions buildOptions(java.util.Properties opts)
           
 I2PSocket connect(Destination peer)
          Create a new connected socket.
 I2PSocket connect(Destination peer, I2PSocketOptions options)
          Create a new connected socket.
 void destroySocketManager()
          Destroy the socket manager, freeing all the associated resources.
 long getAcceptTimeout()
           
 ConnectionManager getConnectionManager()
           
 I2PSocketOptions getDefaultOptions()
           
 java.lang.String getName()
           
 I2PServerSocket getServerSocket()
           
 I2PSession getSession()
           
 void init(I2PAppContext context, I2PSession session, java.util.Properties opts, java.lang.String name)
           
 java.util.Set listSockets()
          Retrieve a set of currently connected I2PSockets, either initiated locally or remotely.
 boolean ping(Destination peer, long timeoutMs)
          Ping the specified peer, returning true if they replied to the ping within the timeout specified, false otherwise.
 I2PSocket receiveSocket()
           
 void removeDisconnectListener(I2PSocketManager.DisconnectListener lsnr)
           
 void setAcceptTimeout(long ms)
          How long should we wait for the client to .accept() a socket before sending back a NACK/Close?
 void setDefaultOptions(I2PSocketOptions options)
           
 void setName(java.lang.String name)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_MAX_STREAMS

public static final java.lang.String PROP_MAX_STREAMS
how many streams will we allow at once?

See Also:
Constant Field Values
Constructor Detail

I2PSocketManagerFull

public I2PSocketManagerFull()

I2PSocketManagerFull

public I2PSocketManagerFull(I2PAppContext context,
                            I2PSession session,
                            java.util.Properties opts,
                            java.lang.String name)
Parameters:
context -
session -
opts -
name -
Method Detail

init

public void init(I2PAppContext context,
                 I2PSession session,
                 java.util.Properties opts,
                 java.lang.String name)
Specified by:
init in interface I2PSocketManager
Parameters:
context -
session -
opts -
name -

buildOptions

public I2PSocketOptions buildOptions()
Specified by:
buildOptions in interface I2PSocketManager

buildOptions

public I2PSocketOptions buildOptions(java.util.Properties opts)
Specified by:
buildOptions in interface I2PSocketManager

getSession

public I2PSession getSession()
Specified by:
getSession in interface I2PSocketManager

getConnectionManager

public ConnectionManager getConnectionManager()

receiveSocket

public I2PSocket receiveSocket()
                        throws I2PException,
                               java.net.SocketTimeoutException
Returns:
connected I2PSocket
Throws:
I2PException
java.net.SocketTimeoutException

ping

public boolean ping(Destination peer,
                    long timeoutMs)
Ping the specified peer, returning true if they replied to the ping within the timeout specified, false otherwise. This call blocks.

Specified by:
ping in interface I2PSocketManager
Parameters:
peer -
timeoutMs -
Returns:
true on success, false on failure

setAcceptTimeout

public void setAcceptTimeout(long ms)
How long should we wait for the client to .accept() a socket before sending back a NACK/Close?

Specified by:
setAcceptTimeout in interface I2PSocketManager
Parameters:
ms - milliseconds to wait, maximum

getAcceptTimeout

public long getAcceptTimeout()
Specified by:
getAcceptTimeout in interface I2PSocketManager

setDefaultOptions

public void setDefaultOptions(I2PSocketOptions options)
Specified by:
setDefaultOptions in interface I2PSocketManager

getDefaultOptions

public I2PSocketOptions getDefaultOptions()
Specified by:
getDefaultOptions in interface I2PSocketManager

getServerSocket

public I2PServerSocket getServerSocket()
Specified by:
getServerSocket in interface I2PSocketManager

connect

public I2PSocket connect(Destination peer,
                         I2PSocketOptions options)
                  throws I2PException,
                         java.net.NoRouteToHostException
Create a new connected socket. Blocks until the socket is created, unless the connectDelay option (i2p.streaming.connectDelay) is set and greater than zero. If so this will return immediately, and the client may quickly write initial data to the socket and this data will be bundled in the SYN packet.

Specified by:
connect in interface I2PSocketManager
Parameters:
peer - Destination to connect to
options - I2P socket options to be used for connecting
Returns:
I2PSocket if successful
Throws:
java.net.NoRouteToHostException - if the peer is not found or not reachable
I2PException - if there is some other I2P-related problem

connect

public I2PSocket connect(Destination peer)
                  throws I2PException,
                         java.net.NoRouteToHostException
Create a new connected socket. Blocks until the socket is created, unless the connectDelay option (i2p.streaming.connectDelay) is set and greater than zero in the default options. If so this will return immediately, and the client may quickly write initial data to the socket and this data will be bundled in the SYN packet.

Specified by:
connect in interface I2PSocketManager
Parameters:
peer - Destination to connect to
Returns:
I2PSocket if successful
Throws:
java.net.NoRouteToHostException - if the peer is not found or not reachable
I2PException - if there is some other I2P-related problem

destroySocketManager

public void destroySocketManager()
Destroy the socket manager, freeing all the associated resources. This method will block untill all the managed sockets are closed.

Specified by:
destroySocketManager in interface I2PSocketManager

listSockets

public java.util.Set listSockets()
Retrieve a set of currently connected I2PSockets, either initiated locally or remotely.

Specified by:
listSockets in interface I2PSocketManager
Returns:
set of currently connected I2PSockets

getName

public java.lang.String getName()
Specified by:
getName in interface I2PSocketManager

setName

public void setName(java.lang.String name)
Specified by:
setName in interface I2PSocketManager

addDisconnectListener

public void addDisconnectListener(I2PSocketManager.DisconnectListener lsnr)
Specified by:
addDisconnectListener in interface I2PSocketManager

removeDisconnectListener

public void removeDisconnectListener(I2PSocketManager.DisconnectListener lsnr)
Specified by:
removeDisconnectListener in interface I2PSocketManager