java.lang.Object
net.i2p.sam.SAMStreamSession.StreamSender
All Implemented Interfaces:
Runnable
Direct Known Subclasses:
SAMStreamSession.V1StreamSender, SAMv2StreamSession.V2StreamSender
Enclosing class:
SAMStreamSession

protected abstract static class SAMStreamSession.StreamSenderextends Object implements Runnable
Lets us push data through the stream without blocking, (even after exceeding the I2PSocket's buffer).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final int
    Stream id assigned by the client for this sender.
    protected final I2PSocket
    i2pSocket.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StreamSender(I2PSocket s, int id)
    Create a new StreamSender.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    abstract void
    run()
    Writes the sender's queued payloads to the peer; each subclass implements it.
    abstract void
    sendBytes(InputStream in, int size)
    Send bytes through the SAM STREAM session socket sender.
    abstract void
    Stop a SAM STREAM session socket sender gracefully: stop the sender thread once all pending data has been sent.
    abstract void
    Stop a SAM STREAM session socket sender thread immediately.

    Methods inherited from class Object

    clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • _id

      protected final int _id
      Stream id assigned by the client for this sender.
    • i2pSocket

      protected final I2PSocket i2pSocket
      i2pSocket.
  • Constructor Details

    • StreamSender

      public StreamSender(I2PSocket s, int id) throws IOException
      Create a new StreamSender.
      Parameters:
      s - the I2PSocket to write to
      id - the stream id
      Throws:
      IOException - if the output stream cannot be obtained
  • Method Details

    • sendBytes

      public abstract void sendBytes(InputStream in, int size) throws IOException
      Send bytes through the SAM STREAM session socket sender.
      Parameters:
      in - Data input stream
      size - Count of bytes to send
      Throws:
      IOException - if the client didnt provide enough data
    • stopRunning

      public abstract void stopRunning()
      Stop a SAM STREAM session socket sender thread immediately.
    • shutDownGracefully

      public abstract void shutDownGracefully()
      Stop a SAM STREAM session socket sender gracefully: stop the sender thread once all pending data has been sent.
    • run

      public abstract void run()
      Writes the sender's queued payloads to the peer; each subclass implements it.
      Specified by:
      run in interface Runnable