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
SAM RAW session class.
- Author:
- human
-
Field Summary
Fields inherited from class net.i2p.sam.SAMMessageSession
_isOwnSession, _log
-
Constructor Summary
ModifierConstructorDescriptionSAMRawSession
(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
Modifier and TypeMethodDescriptionprotected void
messageReceived
(byte[] msg, int proto, int fromPort, int toPort) Handle a new received messageboolean
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 sessionMethods inherited from class net.i2p.sam.SAMMessageSession
close, getDestination, getI2PSession, getListenPort, getListenProtocol, sendBytesThroughMessageSession, sendBytesThroughMessageSession, start
-
Field Details
-
RAW_SIZE_MAX
public static final int RAW_SIZE_MAX- See Also:
-
recv
-
-
Constructor Details
-
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 Details
-
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:
dest
- Destinationdata
- Bytes to be sentproto
- if 0, will use PROTO_DATAGRAM_RAW (18)- 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
-