Class WsConnection.TaskHandle

java.lang.Object
com.alibaba.dashscope.transport.ws.WsConnection.TaskHandle
All Implemented Interfaces:
TaskChannel, AutoCloseable
Enclosing class:
WsConnection

public final class WsConnection.TaskHandle extends Object implements TaskChannel
One task's channel over this shared connection. close() detaches the task only; a binary-lane owner closed before its terminal event tears the connection down.
  • Method Details

    • taskId

      public String taskId()
      Specified by:
      taskId in interface TaskChannel
    • sendText

      public void sendText(String json)
      Description copied from interface: TaskChannel
      Send a text frame (already-serialized JSON). Full upstream queue → SdkException.
      Specified by:
      sendText in interface TaskChannel
    • sendBinary

      public void sendBinary(ByteBuffer data)
      Description copied from interface: TaskChannel
      Send a raw binary frame (no header; ownership rules apply on shared connections).
      Specified by:
      sendBinary in interface TaskChannel
    • recv

      public TaskEvent recv(Duration timeout)
      Description copied from interface: TaskChannel
      Next inbound item for this task, blocking up to timeout; null on timeout. FAILURE events throw their carried exception.
      Specified by:
      recv in interface TaskChannel
    • close

      public void close()
      Description copied from interface: TaskChannel
      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 TaskChannel.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
      Specified by:
      close in interface TaskChannel