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

      class SAMRawSession
      extends SAMMessageSession

  SAM RAW session class.

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `static int` | `RAW_SIZE_MAX`
    `protected SAMRawReceiver` | `recv`

    - ### Fields inherited from class net.i2p.sam.SAMMessageSession

      `_isOwnSession, _log`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `SAMRawSession(I2PSession sess, Properties props, int listenProtocol, int listenPort, SAMRawReceiver recv)` Create a new SAM RAW session on an existing I2P session.
    `` | `SAMRawSession(InputStream destStream, Properties props, SAMRawReceiver recv)` Create a new SAM RAW session.
    `protected` | `SAMRawSession(String dest, Properties props, SAMRawReceiver recv)` Create a new SAM RAW session.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `messageReceived(byte[] msg, int proto, int fromPort, int toPort)` Handle a new received message
    `boolean` | `sendBytes(String dest, byte[] data, int proto, int fromPort, int toPort)` Send bytes through a SAM RAW 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 RAW session.
    `protected void` | `shutDown()` 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`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### RAW_SIZE_MAX

          public static final int RAW_SIZE_MAX

      See Also:
        Constant Field Values

    - #### recv

          protected SAMRawReceiver recv

  - ### Constructor Detail

    - #### 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:
        `IOException`
        `DataFormatException`
        `I2PSessionException`

    - #### 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 session
        `recv` - Object that will receive incoming data
      Throws:
        `IOException`
        `DataFormatException`
        `I2PSessionException`

    - #### 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 session
        `recv` - Object that will receive incoming data
      Throws:
        `IOException`
        `DataFormatException`
        `I2PSessionException`

  - ### Method Detail

    - #### 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 class `SAMMessageSession`
      Parameters:
        `msg` - Message payload

    - #### 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:
        `sendBytes` in interface `SAMMessageSess`
      Specified by:
        `sendBytes` in class `SAMMessageSession`
      Parameters:
        `data` - Bytes to be sent
        `proto` - if 0, will use PROTO_DATAGRAM_RAW (18)
        `dest` - Destination
      Returns:
        True if the data was sent, false otherwise
      Throws:
        `DataFormatException` - on unknown / bad dest
        `I2PSessionException` - 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:
        `DataFormatException`
        `I2PSessionException`

    - #### shutDown

          protected void shutDown()

      Description copied from class: `SAMMessageSession`
      Do whatever is needed to shutdown the SAM session
      Specified by:
        `shutDown` in class `SAMMessageSession`