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
FieldsFields inherited from class net.i2p.sam.SAMMessageSession
_isOwnSession, _log -
Constructor Summary
ConstructorsModifierConstructorDescriptionSAMRawSession(InputStream destStream, Properties props, SAMRawReceiver recv) Create a new SAM RAW session.protectedSAMRawSession(String dest, Properties props, SAMRawReceiver recv) Create a new SAM RAW session.protectedSAMRawSession(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 voidmessageReceived(byte[] msg, int proto, int fromPort, int toPort) Handle a new received messagebooleanSend bytes through a SAM RAW session.booleansendBytes(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 voidshutDown()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:
IOExceptionDataFormatExceptionI2PSessionException
-
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:
IOExceptionDataFormatExceptionI2PSessionException
-
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:
IOExceptionDataFormatExceptionI2PSessionException- 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:
sendBytesin interfaceSAMMessageSess- Specified by:
sendBytesin 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:
DataFormatExceptionI2PSessionException- Since:
- 0.9.25
-
messageReceived
protected void messageReceived(byte[] msg, int proto, int fromPort, int toPort) Description copied from class:SAMMessageSessionHandle a new received message- Specified by:
messageReceivedin classSAMMessageSession- Parameters:
msg- Message payload
-
shutDown
protected void shutDown()Description copied from class:SAMMessageSessionDo whatever is needed to shutdown the SAM session- Specified by:
shutDownin classSAMMessageSession
-