- All Superinterfaces:
AutoCloseable, Closeable
- All Known Subinterfaces:
Session
- All Known Implementing Classes:
MasterSession, SAMDatagramSession, SAMMessageSession, SAMRawSession, SAMStreamSession, SAMv2StreamSession, SAMv3DatagramSession, SAMv3RawSession, SAMv3StreamSession
Base for datagram/raw sessions (v1/v3) and also SAMStreamSession.
- See Also:
Method Summary
All MethodsModifier and TypeMethodDescriptionvoidclose()Close a SAM message-based session.Get the SAM message-based session Destination.intGet the port for this session's listener.intGet the I2CP protocol for this session's listener.lookupDest(String name) Lookup a destination through the I2CP session.booleanSend bytes through a SAM message-based 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 message-based session, with per-message extended options.voidstart()Start a SAM message-based session.
Method Details
start
void start()Start a SAM message-based session. MUST be called after constructor.close
void close()Close a SAM message-based session.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
getDestination
Destination getDestination()Get the SAM message-based session Destination.- Returns:
- The SAM message-based session Destination.
sendBytes
boolean sendBytes(String dest, byte[] data, int proto, int fromPort, int toPort) throws DataFormatException, I2PSessionException Send bytes through a SAM message-based session.- Parameters:
dest- the base32 destination or .b32.i2p hostname to send todata- the bytes to sendproto- the I2CP protocol to send underfromPort- the I2CP from port, 0 for the defaulttoPort- the I2CP to port, 0 for the default- Returns:
- True if the data was sent, false otherwise
- Throws:
DataFormatException- on unknown / bad destI2PSessionException- on serious error, probably session closed
sendBytes
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 message-based session, with per-message extended options.- Parameters:
dest- the base32 destination or .b32.i2p hostname to send todata- the bytes to sendproto- the I2CP protocol to send underfromPort- the I2CP from port, 0 for the defaulttoPort- the I2CP to port, 0 for the defaultsendLeaseSet- true to include the LeaseSet in the messagesendTags- the number of tunnels to include, 0 to leave as defaulttagThreshold- the build success ratio below which no tunnel is sent, 0 for defaultexpiration- the lease lifetime in seconds from now, 0 to leave as default- Returns:
- True if the data was sent, false otherwise
- Throws:
DataFormatException- if dest is not a valid destinationI2PSessionException- on serious error, probably session closed
getListenProtocol
int getListenProtocol()Get the I2CP protocol for this session's listener.- Returns:
- the I2CP protocol
getListenPort
int getListenPort()Get the port for this session's listener.- Returns:
- the listen port
lookupDest
Lookup a destination through the I2CP session. Blocking.- Parameters:
name- the base32 hostname, or full destination, to resolve- Returns:
- the Destination, or null if it could not be resolved
- Throws:
I2PSessionException- if the lookup does not complete within the 10 second session timeout