java.lang.Object
net.i2p.i2ptunnel.streamr.Subscriber
All Implemented Interfaces:
Sink

public class Subscriberextends Object implements Sink
Server-mode subscriber that manages multiple data sources and handles incoming connections.
  • Field Details

    • ctx

      private final I2PAppContext ctx
      The app context.
    • log

      private final Log log
      The log for the subscriber.
    • subscriptions

      private final Map<MultiSource.MSink, Long> subscriptions
      The subscribers, with their expiration times.
    • multi

      private final MultiSource multi
      The multi source being subscribed to.
    • timer

      private final SimpleTimer2.TimedEvent timer
      The timer expiring the subscribers.
    • timerRunning

      private volatile boolean timerRunning
      True while the timer runs.
    • MAX_SUBSCRIPTIONS

      private static final int MAX_SUBSCRIPTIONS
      Most subscribers allowed.
      See Also:
    • EXPIRATION

      private static final long EXPIRATION
      Time before a subscriber expires.
      See Also:
  • Constructor Details

    • Subscriber

      public Subscriber(MultiSource multi)
      Creates a new subscriber for managing data source connections.
      Parameters:
      multi - the multi-source to register subscriptions with
  • Method Details

    • send

      public void send(Destination dest, int fromPort, int toPort, byte[] data)
      Handles subscription or unsubscription requests. Does not really "send" anywhere; instead interprets the data byte as a control command.
      Specified by:
      send in interface Sink
      Parameters:
      dest - the source destination to subscribe or unsubscribe
      fromPort - the source I2CP port (swapped for replies)
      toPort - the destination I2CP port (swapped for replies)
      data - must be a single byte: 0 to subscribe, 1 to unsubscribe