net.i2p.i2ptunnel.streamr

## Class Pinger

- java.lang.Object
- - net.i2p.i2ptunnel.streamr.Pinger

- All Implemented Interfaces:
    Runnable, Source

      public class Pinger
      extends Object
      implements Source, Runnable

  Connectivity tester that pings I2P destinations at regular intervals to monitor network status

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected boolean` | `running`
    `protected Sink` | `sink`
    `protected Thread` | `thread`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `Pinger(I2PAppContext ctx, int fromPort)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `run()` Main run loop that periodically sends subscribe messages.
    `void` | `setSink(Sink sink)` Sets the destination sink for ping messages.
    `void` | `start()` Starts the pinger thread to send periodic subscribe messages.
    `void` | `stop()` Stops the pinger thread and sends an unsubscribe message.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### running

          protected volatile boolean running

    - #### sink

          protected Sink sink

    - #### thread

          protected final Thread thread

  - ### Constructor Detail

    - #### Pinger

          public Pinger(I2PAppContext ctx,
                        int fromPort)

      Parameters:
        `fromPort` - the I2CP from port

  - ### Method Detail

    - #### run

          public void run()

      Main run loop that periodically sends subscribe messages. Runs until stop() is called.
      Specified by:
        `run` in interface `Runnable`

    - #### setSink

          public void setSink(Sink sink)

      Sets the destination sink for ping messages.
      Specified by:
        `setSink` in interface `Source`
      Parameters:
        `sink` - the sink to receive ping messages

    - #### start

          public void start()

      Starts the pinger thread to send periodic subscribe messages.
      Specified by:
        `start` in interface `Source`

    - #### stop

          public void stop()

      Stops the pinger thread and sends an unsubscribe message.