java.lang.Object
net.i2p.client.streaming.impl.MessageHandler
All Implemented Interfaces:
I2PSessionListener, I2PSessionMuxedListener

class MessageHandlerextends Object implements I2PSessionMuxedListener
Receive raw information from the I2PSession and turn it into Packets, if we can.

I2PSession -> MessageHandler -> PacketHandler -> ConnectionPacketHandler -> MessageInputStream.

  • Field Details

    • _manager

      private final ConnectionManager _manager
      The manager whose messages are handled.
    • _context

      private final I2PAppContext _context
      The context the handler runs in.
    • _log

      private final Log _log
      Logger for this class.
    • _listeners

      private final Set<I2PSocketManager.DisconnectListener> _listeners
      Notified when a destination disconnects.
    • _restartPending

      private final AtomicBoolean _restartPending
      True while a session restart is queued.
  • Constructor Details

    • MessageHandler

      public MessageHandler(I2PAppContext ctx, ConnectionManager mgr)
      Creates a new MessageHandler.
      Parameters:
      ctx - the I2P app context
      mgr - the connection manager
  • Method Details

    • messageAvailable

      public void messageAvailable(I2PSession session, int msgId, long size)
      Instruct the client that the given session has received a message with size # of bytes. This shouldn't be called anymore since we are registering as a muxed listener.
      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
    • messageAvailable

      public void messageAvailable(I2PSession session, int msgId, long size, int proto, int fromPort, int toPort)
      Instruct the client that the given session has received a message with size # of bytes.
      Specified by:
      messageAvailable in interface I2PSessionMuxedListener
      Parameters:
      session - session to notify
      msgId - message number available
      size - size of the message
      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)
      Instruct the client that the session specified seems to be under attack and that the client may wish to move its destination to another router.
      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
    • disconnected

      public void disconnected(I2PSession session)
      Notify the client that the session has been terminated.

      The listeners are not cleared here, so they are notified again after a subsequent connection and disconnection.

      Specified by:
      disconnected in interface I2PSessionListener
      Specified by:
      disconnected in interface I2PSessionMuxedListener
      Parameters:
      session - that has been terminated
    • errorOccurred

      public void errorOccurred(I2PSession session, String message, Throwable error)
      Notify the client that some error occurred.
      Specified by:
      errorOccurred in interface I2PSessionListener
      Specified by:
      errorOccurred in interface I2PSessionMuxedListener
      Parameters:
      session - of the client
      message - to send to the client about the error
      error - the actual error
    • addDisconnectListener

      public void addDisconnectListener(I2PSocketManager.DisconnectListener lsnr)
      Add a disconnect listener.
      Parameters:
      lsnr - the listener to add
    • removeDisconnectListener

      public void removeDisconnectListener(I2PSocketManager.DisconnectListener lsnr)
      Remove a disconnect listener.
      Parameters:
      lsnr - the listener to remove