Class WsConnection
java.lang.Object
com.alibaba.dashscope.transport.ws.WsConnection
- All Implemented Interfaces:
AutoCloseable
A shared physical WebSocket multiplexing many tasks by
header.task_id (audio design §7).
One daemon reader thread (dashscope-ws-reader) demuxes inbound frames into per-task
queues; user threads block on WsConnection.TaskHandle.recv(java.time.Duration). Binary frames carry no task id: the uplink
is claimed by the first task to sendBinary, the downlink by claimBinaryDownlink(java.lang.String)
(or implicitly when exactly one task is active). Viable mix: one ASR uplink + one TTS downlink +
any number of pure-JSON tasks; two concurrent binary streams on one connection raise
sdk.ws.BinaryOwnerConflict.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionfinal classOne task's channel over this shared connection. -
Constructor Summary
ConstructorsConstructorDescriptionWsConnection(HttpTransport transport, String url, String module, RequestOptions options) WsConnection(HttpTransport transport, String url, String module, RequestOptions options, int maxQueueCapacity, Duration connectTimeout) -
Method Summary
Modifier and TypeMethodDescriptionRegister a task on this connection.voidclaimBinaryDownlink(String taskId) Explicitly claim the binary downlink for a task (TTS start does this automatically).voidclaimBinaryUplink(String taskId) Explicitly claim the binary uplink before the first frame (ASR start does this).voidclose()Broadcasts a connection-closed failure to all unfinished tasks and joins the reader (2s).
-
Constructor Details
-
WsConnection
-
WsConnection
public WsConnection(HttpTransport transport, String url, String module, RequestOptions options, int maxQueueCapacity, Duration connectTimeout)
-
-
Method Details
-
attach
Register a task on this connection. Duplicate task_id / connection already closed (by either side) →sdk.ws.IllegalState. -
claimBinaryDownlink
Explicitly claim the binary downlink for a task (TTS start does this automatically). -
claimBinaryUplink
Explicitly claim the binary uplink before the first frame (ASR start does this). -
close
public void close()Broadcasts a connection-closed failure to all unfinished tasks and joins the reader (2s).- Specified by:
closein interfaceAutoCloseable
-