class SAMStreamSession extends Object implements SAMMessageSess
| Modifier and Type | Class and Description |
|---|---|
protected class | SAMStreamSession.DisconnectListenerDisconnectListener. |
class | SAMStreamSession.SAMStreamSessionServerSAMStreamSessionServer |
static class | SAMStreamSession.SAMStreamSessionSocketReaderSAMStreamSessionSocketReader |
class | SAMStreamSession.SAMv1StreamSessionSocketReaderSAMv1StreamSessionSocketReader |
protected static class | SAMStreamSession.StreamSenderLets us push data through the stream without blocking, (even after exceeding
the I2PSocket's buffer). |
| Modifier and Type | Field and Description |
|---|---|
protected boolean | _isOwnSession_isOwnSession. |
protected Log | _log_log. |
protected boolean | canCreatecanCreate. |
static String | DEFAULT_FORCE_FLUSHDEFAULT_FORCE_FLUSH |
protected boolean | forceFlushshould we flush every time we get a STREAM SEND, or leave that up to
the streaming lib to decide? |
static String | PROP_FORCE_FLUSHPROP_FORCE_FLUSH |
protected SAMStreamReceiver | recvrecv. |
protected SAMStreamSession.SAMStreamSessionServer | serverserver. |
protected static int | SOCKET_HANDLER_BUF_SIZESOCKET_HANDLER_BUF_SIZE. |
protected I2PSocketManager | socketMgrsocketMgr. |
| Modifier | Constructor and Description |
|---|---|
protected | SAMStreamSession(I2PSocketManager mgr,
Properties props,
SAMStreamReceiver recv,
int listenport)Create a new SAM STREAM session on an existing socket manager. |
protected | SAMStreamSession(InputStream destStream,
String dir,
Properties props,
SAMStreamReceiver recv)Create a new SAM STREAM session. |
| SAMStreamSession(String dest,
String dir,
Properties props,
SAMStreamReceiver recv)Create a new SAM STREAM session. |
| Modifier and Type | Method and Description |
|---|---|
protected boolean | checkSocketHandlerId(int id)Check whether a SAM STREAM session socket handler id is still in use. |
void | close()Close a SAM STREAM session. |
boolean | closeConnection(int id)Close a connection managed by the SAM STREAM session. |
boolean | connect(int id,
String dest,
Properties props)Connect the SAM STREAM session to the specified Destination |
protected int | createSocketHandler(I2PSocket s,
int id)Create a new SAM STREAM session socket handler, detaching its thread. |
Destination | getDestination()Get the SAM STREAM session Destination. |
int | getListenPort()Get the port for this session's listener. |
int | getListenProtocol()Get the I2CP protocol for this session's listener. |
protected SAMStreamSession.SAMStreamSessionSocketReader | getSocketReader(int id)Get a SAM STREAM session socket handler. |
boolean | isDestroyed()Is the underlying streaming socket manager destroyed? |
Destination | lookupDest(String name)Lookup a destination through the I2CP session. |
protected SAMStreamSession.SAMStreamSessionSocketReader | newSAMStreamSessionSocketReader(I2PSocket s,
int id)Create a new SAM STREAM session socket reader. |
protected SAMStreamSession.StreamSender | newStreamSender(I2PSocket s,
int id)newStreamSender. |
protected void | removeSocketHandler(int id)Remove and gracefully close a SAM STREAM session socket handler. |
boolean | sendBytes(int id,
InputStream in,
int size)Send bytes through a SAM STREAM session. |
boolean | sendBytes(String s,
byte[] b,
int pr,
int fp,
int tp)Unsupported |
boolean | sendBytes(String s,
byte[] b,
int pr,
int fp,
int tp,
boolean sendLeaseSet,
int sendTags,
int tagThreshold,
int expiration)Unsupported |
(package private) boolean | setReceiveLimit(int id,
long limit,
boolean nolimit)Set a receive limit for a stream. |
void | start()Start the SAM STREAM session server, if applicable. |
protected final boolean _isOwnSession
protected final Log _log
protected final boolean canCreate
public static final String DEFAULT_FORCE_FLUSH
protected final boolean forceFlush
public static final String PROP_FORCE_FLUSH
protected final SAMStreamReceiver recv
protected final SAMStreamSession.SAMStreamSessionServer server
protected static final int SOCKET_HANDLER_BUF_SIZE
protected final I2PSocketManager socketMgr
protected SAMStreamSession(I2PSocketManager mgr, Properties props, SAMStreamReceiver recv, int listenport)
props - Properties to setup the I2P sessionrecv - Object that will receive incoming dataprotected SAMStreamSession(InputStream destStream, String dir, Properties props, SAMStreamReceiver recv) throws SAMException
destStream - Input stream containing the binary destination and private keys,
and optional offline signature section (same format as PrivateKeyFile)dir - Session direction ("RECEIVE", "CREATE" or "BOTH") or "__v3__" if extended by SAMv3StreamSessionprops - Properties to setup the I2P sessionrecv - Object that will receive incoming dataSAMExceptionpublic SAMStreamSession(String dest, String dir, Properties props, SAMStreamReceiver recv) throws SAMException
dest - Base64-encoded destination and private keys,
and optional offline signature section (same format as PrivateKeyFile)dir - Session direction ("RECEIVE", "CREATE" or "BOTH") or "__v3__" if extended by SAMv3StreamSessionprops - Properties to setup the I2P sessionrecv - Object that will receive incoming dataSAMExceptionprotected boolean checkSocketHandlerId(int id)
id - Handler idpublic void close()
close in interface Closeableclose in interface AutoCloseableclose in interface SAMMessageSesspublic boolean closeConnection(int id)
id - Connection idpublic boolean connect(int id,
String dest,
Properties props)
throws I2PException,
SAMInvalidDirectionException,
IOExceptionid - Unique id for the connectiondest - Base64-encoded Destination to connect toprops - Options to be used for connectionDataFormatException - if the destination is not validSAMInvalidDirectionException - if trying to connect through a
receive-only sessionConnectException - if the destination refuses connectionsNoRouteToHostException - if the destination can't be reachedInterruptedIOException - if the connection timeoutsI2PException - if there's another I2P-related errorIOExceptionprotected int createSocketHandler(I2PSocket s, int id)
s - Socket to be handledid - Socket id, or 0 if it must be auto-generatedpublic Destination getDestination()
getDestination in interface SAMMessageSesspublic int getListenPort()
getListenPort in interface SAMMessageSesspublic int getListenProtocol()
getListenProtocol in interface SAMMessageSessprotected SAMStreamSession.SAMStreamSessionSocketReader getSocketReader(int id)
id - Handler idpublic boolean isDestroyed()
public Destination lookupDest(String name) throws I2PSessionException
lookupDest in interface SAMMessageSessname - Base64 or b32 destination name to look upI2PSessionExceptionprotected SAMStreamSession.SAMStreamSessionSocketReader newSAMStreamSessionSocketReader(I2PSocket s, int id) throws IOException
s - Socket to be handledid - Unique id assigned to the handlerIOException - if the socket reader cannot be createdprotected SAMStreamSession.StreamSender newStreamSender(I2PSocket s, int id) throws IOException
IOExceptionprotected void removeSocketHandler(int id)
id - Handler id to be removedpublic boolean sendBytes(int id,
InputStream in,
int size)
throws IOExceptionid - Stream Idin - Datastream inputsize - Count of bytes to sendIOExceptionpublic boolean sendBytes(String s, byte[] b, int pr, int fp, int tp) throws I2PSessionException
sendBytes in interface SAMMessageSesss - Destinationb - Bytes to be sentI2PSessionException - alwayspublic boolean sendBytes(String s, byte[] b, int pr, int fp, int tp, boolean sendLeaseSet, int sendTags, int tagThreshold, int expiration) throws I2PSessionException
sendBytes in interface SAMMessageSessI2PSessionException - alwaysboolean setReceiveLimit(int id,
long limit,
boolean nolimit)id - Stream idlimit - the receive limitnolimit - true for no limitpublic void start()
start in interface SAMMessageSess