abstract class SAMMessageSession extends Object implements SAMMessageSess
Modifier and Type | Field and Description |
---|---|
protected boolean |
_isOwnSession |
protected Log |
_log |
Modifier | Constructor and Description |
---|---|
protected |
SAMMessageSession(I2PSession sess,
int listenProtocol,
int listenPort)
Initialize a new SAM message-based session using an existing I2PSession.
|
protected |
SAMMessageSession(InputStream destStream,
Properties props)
Initialize a new SAM message-based session.
|
protected |
SAMMessageSession(String dest,
Properties props)
Initialize a new SAM message-based session.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close a SAM message-based session.
|
Destination |
getDestination()
Get the SAM message-based session Destination.
|
protected I2PSession |
getI2PSession()
Get the I2PSession object used by the SAM message-based session.
|
int |
getListenPort() |
int |
getListenProtocol() |
protected abstract void |
messageReceived(byte[] msg,
int proto,
int fromPort,
int toPort)
Handle a new received message
|
abstract boolean |
sendBytes(String dest,
byte[] data,
int proto,
int fromPort,
int toPort)
Send bytes through a SAM message-based session.
|
protected boolean |
sendBytesThroughMessageSession(String dest,
byte[] data,
int proto,
int fromPort,
int toPort)
Actually send bytes through the SAM message-based session I2PSession
(er...).
|
protected boolean |
sendBytesThroughMessageSession(String dest,
byte[] data,
int proto,
int fromPort,
int toPort,
boolean sendLeaseSet,
int sendTags,
int tagThreshold,
int expiration)
Actually send bytes through the SAM message-based session I2PSession,
using per-message extended options.
|
protected abstract void |
shutDown()
Do whatever is needed to shutdown the SAM session
|
void |
start()
Start a SAM message-based session.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
sendBytes
protected final Log _log
protected final boolean _isOwnSession
protected SAMMessageSession(String dest, Properties props) throws IOException, DataFormatException, I2PSessionException
dest
- Base64-encoded destination and private keys (same format as PrivateKeyFile)props
- Properties to setup the I2P sessionIOException
DataFormatException
I2PSessionException
protected SAMMessageSession(InputStream destStream, Properties props) throws IOException, DataFormatException, I2PSessionException
destStream
- Input stream containing the destination and private keys (same format as PrivateKeyFile)props
- Properties to setup the I2P sessionIOException
DataFormatException
I2PSessionException
protected SAMMessageSession(I2PSession sess, int listenProtocol, int listenPort) throws IOException, DataFormatException, I2PSessionException
IOException
DataFormatException
I2PSessionException
public void start()
SAMMessageSess
start
in interface SAMMessageSess
public Destination getDestination()
getDestination
in interface SAMMessageSess
public int getListenProtocol()
getListenProtocol
in interface SAMMessageSess
public int getListenPort()
getListenPort
in interface SAMMessageSess
public abstract boolean sendBytes(String dest, byte[] data, int proto, int fromPort, int toPort) throws DataFormatException, I2PSessionException
sendBytes
in interface SAMMessageSess
dest
- Destinationdata
- Bytes to be sentDataFormatException
- on unknown / bad destI2PSessionException
- on serious error, probably session closedprotected boolean sendBytesThroughMessageSession(String dest, byte[] data, int proto, int fromPort, int toPort) throws DataFormatException, I2PSessionException
dest
- Destinationdata
- Bytes to be sentproto
- I2CP protocolfromPort
- I2CP from porttoPort
- I2CP to portDataFormatException
- on unknown / bad destI2PSessionException
- on serious error, probably session closedprotected boolean sendBytesThroughMessageSession(String dest, byte[] data, int proto, int fromPort, int toPort, boolean sendLeaseSet, int sendTags, int tagThreshold, int expiration) throws DataFormatException, I2PSessionException
dest
- Destinationdata
- Bytes to be sentproto
- I2CP protocolfromPort
- I2CP from porttoPort
- I2CP to portsendLeaseSet
- true is the usual setting and the I2CP defaultsendTags
- 0 to leave as defaulttagThreshold
- 0 to leave as defaultexpiration
- SECONDS from now, NOT absolute time, 0 to leave as defaultDataFormatException
- on unknown / bad destI2PSessionException
- on serious error, probably session closedpublic void close()
close
in interface Closeable
close
in interface AutoCloseable
close
in interface SAMMessageSess
protected abstract void messageReceived(byte[] msg, int proto, int fromPort, int toPort)
msg
- Message payloadprotected abstract void shutDown()
protected I2PSession getI2PSession()