java.lang.Object
net.i2p.sam.SAMMessageSession.SAMMessageSessionHandler
All Implemented Interfaces:
Runnable, I2PSessionListener, I2PSessionMuxedListener
Enclosing class:
SAMMessageSession

private class SAMMessageSession.SAMMessageSessionHandlerextends Object implements Runnable, I2PSessionMuxedListener
SAM message-based session handler, running in its own thread.
  • Field Details

    • _session

      private final I2PSession _session
      The session whose messages are received.
    • runningLock

      private final Object runningLock
      The lock held while the receiver runs.
    • stillRunning

      private volatile boolean stillRunning
      True while the receiver runs.
  • Constructor Details

    • SAMMessageSessionHandler

      public SAMMessageSessionHandler(InputStream destStream, Properties props) throws I2PSessionException
      Create a new SAM message-based session handler.
      Parameters:
      destStream - Input stream containing the destination keys
      props - Properties to setup the I2P session
      Throws:
      I2PSessionException - if the session cannot be created
    • SAMMessageSessionHandler

      public SAMMessageSessionHandler(I2PSession sess)
      Create a new SAM message-based session handler on an existing I2PSession.
      Parameters:
      sess - the session to receive from
  • Method Details

    • getSession

      public final I2PSession getSession()
      The session.
      Returns:
      the I2PSession this handler was constructed around, either a newly created and connected one or an existing one passed in
    • stopRunning

      public final void stopRunning()
      Stop a SAM message-based session handling thread.
    • run

      public void run()
      Serves the session's listener thread until the session stops.
      Specified by:
      run in interface Runnable
    • disconnected

      public void disconnected(I2PSession session)
      Stops the session when the underlying I2P session drops.
      Specified by:
      disconnected in interface I2PSessionListener
      Specified by:
      disconnected in interface I2PSessionMuxedListener
      Parameters:
      session - the session that was terminated
    • errorOccurred

      public void errorOccurred(I2PSession session, String message, Throwable error)
      Description copied from interface: I2PSessionMuxedListener
      Notify the client that some error occurred. All registered listeners will be called.
      Specified by:
      errorOccurred in interface I2PSessionListener
      Specified by:
      errorOccurred in interface I2PSessionMuxedListener
      Parameters:
      session - the session that reported the error
      message - a human-readable description of the error
      error - the cause, non-null
    • messageAvailable

      public void messageAvailable(I2PSession session, int msgId, long size)
      Fetches the named message with unspecified protocol and ports.
      Specified by:
      messageAvailable in interface I2PSessionListener
      Specified by:
      messageAvailable in interface I2PSessionMuxedListener
      Parameters:
      session - session to notify
      msgId - message number available
      size - size of the message payload in bytes. The I2CP payload size is an int internally and is widened to long here, so the value is never negative
    • messageAvailable

      public void messageAvailable(I2PSession session, int msgId, long size, int proto, int fromPort, int toPort)
      Forward a received message to the SAM client.
      Specified by:
      messageAvailable in interface I2PSessionMuxedListener
      Parameters:
      session - session to notify
      msgId - message number available
      size - size of the message payload in bytes. The I2CP payload size is an int internally and is widened to long here, so the value is never negative
      proto - 1-254 or 0 for unspecified
      fromPort - 1-65535 or 0 for unspecified
      toPort - 1-65535 or 0 for unspecified
    • reportAbuse

      public void reportAbuse(I2PSession session, int severity)
      Logs the abuse report and stops the session.
      Specified by:
      reportAbuse in interface I2PSessionListener
      Specified by:
      reportAbuse in interface I2PSessionMuxedListener
      Parameters:
      session - session to report abuse to
      severity - how bad the abuse is