Package net.i2p.sam
Class SAMv2StreamSession
- java.lang.Object
-
- net.i2p.sam.SAMStreamSession
-
- net.i2p.sam.SAMv2StreamSession
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,SAMMessageSess
class SAMv2StreamSession extends SAMStreamSession
SAMv2 STREAM session class.- Author:
- mkvore
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SAMv2StreamSession.SAMv2StreamSessionSocketReader
SAM STREAM socket reader, running in its own thread.-
Nested classes/interfaces inherited from class net.i2p.sam.SAMStreamSession
SAMStreamSession.DisconnectListener, SAMStreamSession.SAMStreamSessionServer, SAMStreamSession.SAMStreamSessionSocketReader, SAMStreamSession.SAMv1StreamSessionSocketReader, SAMStreamSession.StreamSender
-
-
Field Summary
-
Fields inherited from class net.i2p.sam.SAMStreamSession
_isOwnSession, _log, canCreate, DEFAULT_FORCE_FLUSH, forceFlush, PROP_FORCE_FLUSH, recv, server, SOCKET_HANDLER_BUF_SIZE, socketMgr
-
-
Constructor Summary
Constructors Constructor Description SAMv2StreamSession(InputStream destStream, String dir, Properties props, SAMStreamReceiver recv)
Create a new SAM STREAM session.SAMv2StreamSession(String dest, String dir, Properties props, SAMStreamReceiver recv)
Create a new SAM STREAM session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
connect(int id, String dest, Properties props)
Connect the SAM STREAM session to the specified Destinationprotected SAMStreamSession.SAMStreamSessionSocketReader
newSAMStreamSessionSocketReader(I2PSocket s, int id)
protected SAMStreamSession.StreamSender
newStreamSender(I2PSocket s, int id)
Lets us push data through the stream without blocking, (even after exceeding the I2PSocket's buffer)boolean
setReceiveLimit(int id, long limit, boolean nolimit)
Send bytes through a SAM STREAM session.-
Methods inherited from class net.i2p.sam.SAMStreamSession
checkSocketHandlerId, close, closeConnection, createSocketHandler, getDestination, getListenPort, getListenProtocol, getSocketReader, removeSocketHandler, sendBytes, sendBytes, sendBytes, start
-
-
-
-
Constructor Detail
-
SAMv2StreamSession
public SAMv2StreamSession(String dest, String dir, Properties props, SAMStreamReceiver recv) throws IOException, DataFormatException, SAMException
Create a new SAM STREAM session. Caller MUST call start().- Parameters:
dest
- Base64-encoded destination and private keys (same format as PrivateKeyFile)dir
- Session direction ("RECEIVE", "CREATE" or "BOTH")props
- Properties to setup the I2P sessionrecv
- Object that will receive incoming data- Throws:
IOException
DataFormatException
SAMException
-
SAMv2StreamSession
public SAMv2StreamSession(InputStream destStream, String dir, Properties props, SAMStreamReceiver recv) throws IOException, DataFormatException, SAMException
Create a new SAM STREAM session. Caller MUST call start().- Parameters:
destStream
- Input stream containing the destination and private keys (same format as PrivateKeyFile)dir
- Session direction ("RECEIVE", "CREATE" or "BOTH")props
- Properties to setup the I2P sessionrecv
- Object that will receive incoming data- Throws:
IOException
DataFormatException
SAMException
-
-
Method Detail
-
connect
public boolean connect(int id, String dest, Properties props) throws DataFormatException, SAMInvalidDirectionException
Connect the SAM STREAM session to the specified Destination- Overrides:
connect
in classSAMStreamSession
- Parameters:
id
- Unique id for the connectiondest
- Base64-encoded Destination to connect toprops
- Options to be used for connection- Returns:
- true if the communication with the SAM client is ok
- Throws:
DataFormatException
- if the destination is not validSAMInvalidDirectionException
- if trying to connect through a receive-only session
-
newStreamSender
protected SAMStreamSession.StreamSender newStreamSender(I2PSocket s, int id) throws IOException
Lets us push data through the stream without blocking, (even after exceeding the I2PSocket's buffer)- Overrides:
newStreamSender
in classSAMStreamSession
- Parameters:
s
- I2PSocketid
- Socket ID- Returns:
- v2StreamSender
- Throws:
IOException
-
newSAMStreamSessionSocketReader
protected SAMStreamSession.SAMStreamSessionSocketReader newSAMStreamSessionSocketReader(I2PSocket s, int id) throws IOException
- Overrides:
newSAMStreamSessionSocketReader
in classSAMStreamSession
- Throws:
IOException
-
setReceiveLimit
public boolean setReceiveLimit(int id, long limit, boolean nolimit)
Send bytes through a SAM STREAM session.- Overrides:
setReceiveLimit
in classSAMStreamSession
- Parameters:
id
- Stream IDlimit
- limitationnolimit
- true to limit- Returns:
- True if the data was queued for sending, false otherwise
-
-