java.lang.Object
net.i2p.i2ptunnel.socks.MultiSink<S>
Type Parameters:
S - type of Sink objects managed by this MultiSink
All Implemented Interfaces:
Sink, Source

public class MultiSink<S extends Sink>extends Object implements Source, Sink
Sends to one of many Sinks based on toPort.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final Map<Integer,S>
    Open streams keyed by their SOCKS stream number.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Wrap the port-to-sink map that the caller keeps up to date, so that each send can be dispatched to the sink registered for its destination port.
  • Method Summary

    All Methods
    Modifier and Type
    Method
    Description
    void
    send(Destination from, int fromPort, int toPort, byte[] data)
    Send to a single sink looked up by toPort
    void
    setSink(Sink sink)
    Don't use this - put sinks in the cache.
    void
    Starts the source.

    Methods inherited from class Object

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

    • cache

      private final Map<Integer, S extends Sink> cache
      Open streams keyed by their SOCKS stream number.
  • Constructor Details

    • MultiSink

      public MultiSink(Map<Integer,S> cache)
      Wrap the port-to-sink map that the caller keeps up to date, so that each send can be dispatched to the sink registered for its destination port.
      Parameters:
      cache - map of toPort to Sink
  • Method Details

    • setSink

      public void setSink(Sink sink)
      Don't use this - put sinks in the cache.
      Specified by:
      setSink in interface Source
      Parameters:
      sink - the sink to receive data
    • start

      public void start()
      Description copied from interface: Source
      Starts the source.
      Specified by:
      start in interface Source
    • send

      public void send(Destination from, int fromPort, int toPort, byte[] data)
      Send to a single sink looked up by toPort

      May throw RuntimeException from underlying sinks.

      Specified by:
      send in interface Sink
      Parameters:
      from - sending destination, passed along to the sink, may be null
      fromPort - source port, passed along to the sink
      toPort - port selecting which sink receives the data
      data - the datagram payload to deliver to the destination
      Throws:
      RuntimeException - if the sink selected by toPort fails to send the data