Interface TaskChannel

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
WsConnection.TaskHandle, WsSession

public interface TaskChannel extends AutoCloseable
One task's view over a WebSocket (audio design §3): implemented by WsSession (dedicated socket) and by WsConnection.TaskHandle (a demultiplexed task on a shared socket). Sends are lock-protected; recv(java.time.Duration) blocks on the caller's thread — the SDK starts no per-task callback thread (pull model; users run one send thread + one receive thread).
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Idempotent.
    recv(Duration timeout)
    Next inbound item for this task, blocking up to timeout; null on timeout.
    void
    Send a raw binary frame (no header; ownership rules apply on shared connections).
    void
    Send a text frame (already-serialized JSON).
     
  • Method Details

    • taskId

      String taskId()
    • sendText

      void sendText(String json)
      Send a text frame (already-serialized JSON). Full upstream queue → SdkException.
    • sendBinary

      void sendBinary(ByteBuffer data)
      Send a raw binary frame (no header; ownership rules apply on shared connections).
    • recv

      TaskEvent recv(Duration timeout)
      Next inbound item for this task, blocking up to timeout; null on timeout. FAILURE events throw their carried exception.
    • close

      void close()
      Idempotent. On a shared connection this detaches the task only; if the task owns a binary lane and has not reached its terminal event, the whole shared connection is torn down instead (binary frames carry no task id, so the lane cannot be handed over safely). A local close is surfaced to a blocked recv(java.time.Duration) as a LOCAL_CLOSED event; a binary-owner teardown is surfaced to every unfinished task, including the closer, as a terminal event instead (a thrown failure — or CLOSED if the peer closed the connection concurrently).
      Specified by:
      close in interface AutoCloseable