Class Scout

  • All Implemented Interfaces:
    java.lang.AutoCloseable

    
    public class Scout
     implements AutoCloseable
                        

    Scout for routers and/or peers.

    Scout spawns a task that periodically sends scout messages and waits for Hello replies. Drop the returned Scout to stop the scouting task.

    To launch a scout, use io.zenoh.Zenoh.scout:

    Example using the default blocking queue handler:

    var scoutOptions = new ScoutOptions();
    scoutOptions.setWhatAmI(Set.of(WhatAmI.Peer, WhatAmI.Router));
    
    var scout = Zenoh.scout(scoutOptions);
    BlockingQueue<Optional<Hello>> receiver = scout.getReceiver();
    
    try {
        while (true) {
            Optional<Hello> wrapper = receiver.take();
            if (wrapper.isEmpty()) {
                break;
            }
    
            Hello hello = wrapper.get();
            System.out.println(hello);
        }
    } finally {
        scout.stop();
    }

    Example using a callback:

    var scoutOptions = new ScoutOptions();
    scoutOptions.setWhatAmI(Set.of(WhatAmI.Peer, WhatAmI.Router));
    Zenoh.scout(hello -> {
        //...
        System.out.println(hello);
    }, scoutOptions);
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Field Summary

      Fields 
      Modifier and Type Field Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final Unit stop() Stops the scouting.
      Unit close() Equivalent to stop.
      • Methods inherited from class java.lang.Object

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