Package net.i2p.sam
Class SAMRawSession
- java.lang.Object
-
- net.i2p.sam.SAMMessageSession
-
- net.i2p.sam.SAMRawSession
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
,SAMMessageSess
- Direct Known Subclasses:
SAMv3RawSession
class SAMRawSession extends SAMMessageSession
SAM RAW session class.- Author:
- human
-
-
Field Summary
Fields Modifier and Type Field Description static int
RAW_SIZE_MAX
protected SAMRawReceiver
recv
-
Fields inherited from class net.i2p.sam.SAMMessageSession
_isOwnSession, _log
-
-
Constructor Summary
Constructors Modifier Constructor Description SAMRawSession(InputStream destStream, Properties props, SAMRawReceiver recv)
Create a new SAM RAW session.protected
SAMRawSession(String dest, Properties props, SAMRawReceiver recv)
Create a new SAM RAW session.protected
SAMRawSession(I2PSession sess, Properties props, int listenProtocol, int listenPort, SAMRawReceiver recv)
Create a new SAM RAW session on an existing I2P session.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
messageReceived(byte[] msg, int proto, int fromPort, int toPort)
Handle a new received messageboolean
sendBytes(String dest, byte[] data, int proto, int fromPort, int toPort)
Send bytes through a SAM RAW session.boolean
sendBytes(String dest, byte[] data, int proto, int fromPort, int toPort, boolean sendLeaseSet, int sendTags, int tagThreshold, int expiration)
Send bytes through a SAM RAW session.protected void
shutDown()
Do whatever is needed to shutdown the SAM session-
Methods inherited from class net.i2p.sam.SAMMessageSession
close, getDestination, getI2PSession, getListenPort, getListenProtocol, sendBytesThroughMessageSession, sendBytesThroughMessageSession, start
-
-
-
-
Field Detail
-
RAW_SIZE_MAX
public static final int RAW_SIZE_MAX
- See Also:
- Constant Field Values
-
recv
protected SAMRawReceiver recv
-
-
Constructor Detail
-
SAMRawSession
protected SAMRawSession(String dest, Properties props, SAMRawReceiver recv) throws IOException, DataFormatException, I2PSessionException
Create a new SAM RAW session.- Parameters:
dest
- Base64-encoded destination and private keys (same format as PrivateKeyFile)props
- Properties to setup the I2P sessionrecv
- Object that will receive incoming data- Throws:
IOException
DataFormatException
I2PSessionException
-
SAMRawSession
public SAMRawSession(InputStream destStream, Properties props, SAMRawReceiver recv) throws IOException, DataFormatException, I2PSessionException
Create a new SAM RAW session. Caller MUST call start().- Parameters:
destStream
- Input stream containing the destination and private keys (same format as PrivateKeyFile)props
- Properties to setup the I2P sessionrecv
- Object that will receive incoming data- Throws:
IOException
DataFormatException
I2PSessionException
-
SAMRawSession
protected SAMRawSession(I2PSession sess, Properties props, int listenProtocol, int listenPort, SAMRawReceiver recv) throws IOException, DataFormatException, I2PSessionException
Create a new SAM RAW session on an existing I2P session.- Parameters:
props
- unused for now- Throws:
IOException
DataFormatException
I2PSessionException
- Since:
- 0.9.25
-
-
Method Detail
-
sendBytes
public boolean sendBytes(String dest, byte[] data, int proto, int fromPort, int toPort) throws DataFormatException, I2PSessionException
Send bytes through a SAM RAW session.- Specified by:
sendBytes
in interfaceSAMMessageSess
- Specified by:
sendBytes
in classSAMMessageSession
- Parameters:
data
- Bytes to be sentproto
- if 0, will use PROTO_DATAGRAM_RAW (18)dest
- Destination- Returns:
- True if the data was sent, false otherwise
- Throws:
DataFormatException
- on unknown / bad destI2PSessionException
- on serious error, probably session closed
-
sendBytes
public boolean sendBytes(String dest, byte[] data, int proto, int fromPort, int toPort, boolean sendLeaseSet, int sendTags, int tagThreshold, int expiration) throws DataFormatException, I2PSessionException
Send bytes through a SAM RAW session.- Throws:
DataFormatException
I2PSessionException
- Since:
- 0.9.25
-
messageReceived
protected void messageReceived(byte[] msg, int proto, int fromPort, int toPort)
Description copied from class:SAMMessageSession
Handle a new received message- Specified by:
messageReceived
in classSAMMessageSession
- Parameters:
msg
- Message payload
-
shutDown
protected void shutDown()
Description copied from class:SAMMessageSession
Do whatever is needed to shutdown the SAM session- Specified by:
shutDown
in classSAMMessageSession
-
-