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 intDGRAM_SIZE_MAXprotected SAMDatagramReceiverrecv- 
Fields inherited from class net.i2p.sam.SAMMessageSession
_isOwnSession, _log 
 - 
 
- 
Constructor Summary
Constructors Modifier Constructor Description SAMDatagramSession(InputStream destStream, Properties props, SAMDatagramReceiver recv)Create a new SAM DATAGRAM session.protectedSAMDatagramSession(String dest, Properties props, SAMDatagramReceiver recv)Create a new SAM DATAGRAM session.protectedSAMDatagramSession(I2PSession sess, Properties props, int listenPort, SAMDatagramReceiver recv)Create a new SAM DATAGRAM session on an existing I2P session. 
- 
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidmessageReceived(byte[] msg, int proto, int fromPort, int toPort)Handle a new received messagebooleansendBytes(String dest, byte[] data, int proto, int fromPort, int toPort)Send bytes through a SAM DATAGRAM 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 DATAGRAM session.protected voidshutDown()Do whatever is needed to shutdown the SAM session- 
Methods inherited from class net.i2p.sam.SAMMessageSession
close, getDestination, getI2PSession, getListenPort, getListenProtocol, sendBytesThroughMessageSession, sendBytesThroughMessageSession, start 
 - 
 
 - 
 
- 
- 
Field Detail
- 
DGRAM_SIZE_MAX
public static final int DGRAM_SIZE_MAX
- See Also:
 - Constant Field Values
 
 
- 
recv
protected SAMDatagramReceiver recv
 
 - 
 
- 
Constructor Detail
- 
SAMDatagramSession
protected SAMDatagramSession(String dest, Properties props, SAMDatagramReceiver recv) throws IOException, DataFormatException, I2PSessionException
Create 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:
 IOExceptionDataFormatExceptionI2PSessionException
 
- 
SAMDatagramSession
public SAMDatagramSession(InputStream destStream, Properties props, SAMDatagramReceiver recv) throws IOException, DataFormatException, I2PSessionException
Create 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:
 IOExceptionDataFormatExceptionI2PSessionException
 
- 
SAMDatagramSession
protected SAMDatagramSession(I2PSession sess, Properties props, int listenPort, SAMDatagramReceiver recv) throws IOException, DataFormatException, I2PSessionException
Create a new SAM DATAGRAM session on an existing I2P session.- Parameters:
 props- unused for now- Throws:
 IOExceptionDataFormatExceptionI2PSessionException- Since:
 - 0.9.25
 
 
 - 
 
- 
Method Detail
- 
sendBytes
public boolean sendBytes(String dest, byte[] data, int proto, int fromPort, int toPort) throws DataFormatException, I2PSessionException
Send bytes through a SAM DATAGRAM session.- Specified by:
 sendBytesin interfaceSAMMessageSess- Specified by:
 sendBytesin 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, I2PSessionException
Send bytes through a SAM DATAGRAM 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
 
 - 
 
 -