Package net.i2p.sam
Class SAMDatagramSession
java.lang.Object
net.i2p.sam.SAMMessageSession
net.i2p.sam.SAMDatagramSession
- All Implemented Interfaces:
Closeable
,AutoCloseable
,SAMMessageSess
- Direct Known Subclasses:
SAMv3DatagramSession
class SAMDatagramSession extends SAMMessageSession
SAM DATAGRAM session class.
- Author:
- human
-
Field Summary
Fields Modifier and Type Field Description static int
DGRAM_SIZE_MAX
protected SAMDatagramReceiver
recv
-
Constructor Summary
Constructors Modifier Constructor Description SAMDatagramSession(InputStream destStream, Properties props, SAMDatagramReceiver recv)
Create a new SAM DATAGRAM session.protected
SAMDatagramSession(String dest, Properties props, SAMDatagramReceiver recv)
Create a new SAM DATAGRAM session.protected
SAMDatagramSession(I2PSession sess, Properties props, int listenPort, SAMDatagramReceiver recv)
Create a new SAM DATAGRAM session on an existing I2P session. -
Method Summary
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 DATAGRAM 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 DATAGRAM 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
-
DGRAM_SIZE_MAX
public static final int DGRAM_SIZE_MAX- See Also:
- Constant Field Values
-
recv
-
-
Constructor Details
-
SAMDatagramSession
protected SAMDatagramSession(String dest, Properties props, SAMDatagramReceiver recv) throws IOException, DataFormatException, I2PSessionExceptionCreate a new SAM DATAGRAM session.- Parameters:
dest
- Base64-encoded destination (private key)props
- Properties to setup the I2P sessionrecv
- Object that will receive incoming data- Throws:
IOException
DataFormatException
I2PSessionException
-
SAMDatagramSession
public SAMDatagramSession(InputStream destStream, Properties props, SAMDatagramReceiver recv) throws IOException, DataFormatException, I2PSessionExceptionCreate a new SAM DATAGRAM session. Caller MUST call start().- Parameters:
destStream
- Input stream containing the destination keysprops
- Properties to setup the I2P sessionrecv
- Object that will receive incoming data- Throws:
IOException
DataFormatException
I2PSessionException
-
SAMDatagramSession
protected SAMDatagramSession(I2PSession sess, Properties props, int listenPort, SAMDatagramReceiver recv) throws IOException, DataFormatException, I2PSessionExceptionCreate a new SAM DATAGRAM 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, I2PSessionExceptionSend bytes through a SAM DATAGRAM session.- Specified by:
sendBytes
in interfaceSAMMessageSess
- Specified by:
sendBytes
in classSAMMessageSession
- Parameters:
dest
- Destinationdata
- Bytes to be sentproto
- ignored, will always use PROTO_DATAGRAM (17)- 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, I2PSessionExceptionSend bytes through a SAM DATAGRAM 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
-