Interface ZCLCommandResponseStream


public interface ZCLCommandResponseStream
This type represents a stream of responses to a broadcast operation. It can be closed by the client using the close() method is called. The ZCLCommandResponseStream is used to process a stream of responses from a ZigBee network. Responses are consumed by registering a handler with forEach(Predicate). Responses received before a handler is registered are buffered until a handler is registered, or until the close method is called. A handler consumes events returning true to continue delivery. At some point the ZigBee service invocation will terminate event delivery by sending a close event (a ZCLCommandResponse which returns true from ZCLCommandResponse.isEnd(). After a close event the handler function will be dereferenced.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Closes this response, indicating that no further responses are needed.
    void
    Registers a handler that will be called for each of the received responses.
  • Method Details

    • close

      void close()
      Closes this response, indicating that no further responses are needed. Any buffered responses will be discarded, and a close event will be sent to a handler if it is registered.
    • forEach

      void forEach(Predicate<? super ZCLCommandResponse> handler)
      Registers a handler that will be called for each of the received responses. Only one handler may be registered. Any responses that arrive before a handler is registered will be buffered and pushed into the handler when it is registered. If the handler returns false from its accept method then the handler will be released and no further events will be delivered. Any remaining buffered events will be discarded, and this object marked as closed. If the handler does not close the stream early then the ZigBee service implementation will eventually send a close event.
      Parameters:
      handler - A handler to process ZCLCommandResponse objects
      Throws:
      IllegalStateException - if a handler has already been registered, or if this object has been closed (a ZCLCommandResponse which returns true from ZCLCommandResponse.isEnd(). After a close event the handler function will be dereferenced.