Package net.i2p.sam

Class SAMMessageSession

    • Field Detail

      • _log

        protected final Log _log
      • _isOwnSession

        protected final boolean _isOwnSession
    • Method Detail

      • start

        public void start()
        Description copied from interface: SAMMessageSess
        Start a SAM message-based session. MUST be called after constructor.
        Specified by:
        start in interface SAMMessageSess
      • getDestination

        public Destination getDestination()
        Get the SAM message-based session Destination.
        Specified by:
        getDestination in interface SAMMessageSess
        Returns:
        The SAM message-based session Destination.
      • sendBytesThroughMessageSession

        protected boolean sendBytesThroughMessageSession​(String dest,
                                                         byte[] data,
                                                         int proto,
                                                         int fromPort,
                                                         int toPort)
                                                  throws DataFormatException,
                                                         I2PSessionException
        Actually send bytes through the SAM message-based session I2PSession (er...).
        Parameters:
        dest - Destination
        data - Bytes to be sent
        proto - I2CP protocol
        fromPort - I2CP from port
        toPort - I2CP to port
        Returns:
        True if the data was sent, false otherwise
        Throws:
        DataFormatException - on unknown / bad dest
        I2PSessionException - on serious error, probably session closed
      • sendBytesThroughMessageSession

        protected boolean sendBytesThroughMessageSession​(String dest,
                                                         byte[] data,
                                                         int proto,
                                                         int fromPort,
                                                         int toPort,
                                                         boolean sendLeaseSet,
                                                         int sendTags,
                                                         int tagThreshold,
                                                         int expiration)
                                                  throws DataFormatException,
                                                         I2PSessionException
        Actually send bytes through the SAM message-based session I2PSession, using per-message extended options. For efficiency, use the method without all the extra options if they are all defaults.
        Parameters:
        dest - Destination
        data - Bytes to be sent
        proto - I2CP protocol
        fromPort - I2CP from port
        toPort - I2CP to port
        sendLeaseSet - true is the usual setting and the I2CP default
        sendTags - 0 to leave as default
        tagThreshold - 0 to leave as default
        expiration - SECONDS from now, NOT absolute time, 0 to leave as default
        Returns:
        True if the data was sent, false otherwise
        Throws:
        DataFormatException - on unknown / bad dest
        I2PSessionException - on serious error, probably session closed
        Since:
        0.9.24
      • messageReceived

        protected abstract void messageReceived​(byte[] msg,
                                                int proto,
                                                int fromPort,
                                                int toPort)
        Handle a new received message
        Parameters:
        msg - Message payload
      • shutDown

        protected abstract void shutDown()
        Do whatever is needed to shutdown the SAM session
      • getI2PSession

        protected I2PSession getI2PSession()
        Get the I2PSession object used by the SAM message-based session.
        Returns:
        The I2PSession of the SAM message-based session