Class HandlerSubscriber

  • All Implemented Interfaces:
    io.zenoh.session.SessionDeclaration , java.lang.AutoCloseable

    
    public final class HandlerSubscriber<R extends Object>
    extends Subscriber
                        

    Subscriber using a io.zenoh.handlers.Handler for handling incoming samples.

    Example using the default handler:

    try (Session session = Zenoh.open(config)) {
        try (HandlerSubscriber<BlockingQueue<Optional<Sample>>> subscriber = session.declareSubscriber(keyExpr)) {
            BlockingQueue<Optional<Sample>> receiver = subscriber.getReceiver();
            assert receiver != null;
            while (true) {
                Optional<Sample> wrapper = receiver.take();
                if (wrapper.isEmpty()) {
                    break;
                }
                System.out.println(wrapper.get());
            }
        }
    }
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
    • Constructor Summary

      Constructors 
      Constructor Description
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
    • Method Summary

      Modifier and Type Method Description
      final R getReceiver()
      • Methods inherited from class io.zenoh.pubsub.Subscriber

        close, getKeyExpr, isValid, undeclare
      • Methods inherited from class java.lang.Object

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