Class ScenePorts

java.lang.Object
com.victorvalentim.zividomelive.ScenePorts

public final class ScenePorts extends Object
Activation-scoped boundary for optional MIDI, OSC, or device adapters.

The core library knows only application-defined message values. Input is bounded and delivered on the Processing thread; output transport and backpressure remain adapter-owned. The default input queue retains at most 256 messages, drops the oldest on overflow, and invokes at most 32 handlers per frame.

Pause drops queued input and rejects new input until resume; it never replays stale device messages. Activation disposal closes connected adapters in reverse registration order.

API stability: Advanced Stable.

Since:
2.0.0
  • Method Details

    • connectInput

      public <T> void connectInput(SceneInputPort<T> port, Consumer<? super T> handler)
      Connects one external source to a handler owned by this scene activation.

      When the bounded queue is full, the oldest pending message is discarded so the activation can continue receiving current device state. The adapter may publish from any thread; the scene handler never runs on that producer thread.

      Type Parameters:
      T - message type defined by the adapter
      Parameters:
      port - external input adapter owned by this activation after connection
      handler - scene handler invoked at a Processing frame boundary
    • connectOutput

      public <T> SceneOutputPort<T> connectOutput(SceneOutputPort<T> port)
      Connects a non-blocking output adapter and returns an activation-guarded view of it.

      After pause or disposal, the managed view returns false without forwarding the value. The runtime retains ownership of the connected adapter's AutoCloseable lifecycle.

      Type Parameters:
      T - message type defined by the adapter
      Parameters:
      port - external output adapter owned by this activation after connection
      Returns:
      activation-guarded output port
    • getDroppedInputCount

      public long getDroppedInputCount()
      Returns:
      cumulative number of oldest pending messages discarded due to queue pressure
    • getPendingInputCount

      public int getPendingInputCount()
      Returns:
      number of input messages waiting for a future frame boundary