java.lang.Object
net.i2p.sam.client.SAMStreamSend.Sender
All Implemented Interfaces:
Runnable
Enclosing class:
SAMStreamSend

private class SAMStreamSend.Senderextends Object implements Runnable
One open SAM session sending data.
  • Field Details

    • _connectionId

      private final String _connectionId
      The SAM connection id.
    • _remoteDestination

      private String _remoteDestination
      The destination being sent to.
    • _in

      private InputStream _in
      Stream the data is read from.
    • _closed

      private volatile boolean _closed
      Whether the session has been closed.
    • _started

      private long _started
      When the session opened.
    • _totalSent

      private long _totalSent
      Total bytes sent so far.
    • _samOut

      private final OutputStream _samOut
      Stream for sending through this session.
    • _eventHandler

      private final SAMEventHandler _eventHandler
      Handler for this session's events.
    • _mode

      private final int _mode
      The send mode to run.
    • _dgSock

      private final DatagramSocket _dgSock
      Datagram socket for datagram modes.
    • _dgSAM

      private final InetSocketAddress _dgSAM
      Bridge address for datagram sends.
  • Constructor Details

    • Sender

      public Sender(OutputStream samOut, SAMEventHandler eventHandler, int mode) throws IOException
      Registers a sender with the stream, opening a datagram socket for datagram modes.
      Parameters:
      samOut - the SAM output stream for stream modes, null for datagram modes
      eventHandler - the handler tracking events for this stream
      mode - the SAM mode, stream, datagram or raw
      Throws:
      IOException - if the datagram socket cannot be opened
  • Method Details

    • openConnection

      public boolean openConnection()
      Reads the destination key from disk and issues STREAM CONNECT.
      Returns:
      true if the bridge reported the stream connected, false on any error
    • getConnectionId

      public String getConnectionId()
      SAM connection id.
      Returns:
      the connection id
    • getDestination

      public String getDestination()
      Remote destination of the stream.
      Returns:
      the remote destination read from the dest file, or null before the connection is opened
    • closed

      public void closed()
      Closes the stream once and records its lifetime in the statistics.
    • run

      public void run()
      Sends the data file over the stream in chunks until it ends or closes.
      Specified by:
      run in interface Runnable