Package io.agentscope.core.studio
Class StudioWebSocketClient
java.lang.Object
io.agentscope.core.studio.StudioWebSocketClient
WebSocket client for real-time communication with AgentScope Studio.
This client uses Socket.IO to connect to Studio's /python namespace and receive user input events. It maintains a persistent connection with automatic reconnection support.
The client listens for "forwardUserInput" events from Studio, which are sent when a user provides input through the web interface. The input is then delivered to the waiting agent via a Mono.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classData structure representing user input from Studio. -
Constructor Summary
ConstructorsConstructorDescriptionStudioWebSocketClient(StudioConfig config) Creates a new Studio WebSocket client. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the WebSocket connection and releases resources.reactor.core.publisher.Mono<Void>connect()Connects to Studio's WebSocket endpoint (/python namespace).booleanChecks if the WebSocket is currently connected.reactor.core.publisher.Mono<StudioWebSocketClient.UserInputData>waitForInput(String requestId) Waits for user input matching the given request ID.
-
Constructor Details
-
StudioWebSocketClient
Creates a new Studio WebSocket client.- Parameters:
config- Configuration for Studio connection
-
-
Method Details
-
connect
Connects to Studio's WebSocket endpoint (/python namespace).This establishes a Socket.IO connection with authentication via run_id. The connection includes automatic reconnection with exponential backoff.
- Returns:
- A Mono that completes when the connection is established
-
waitForInput
public reactor.core.publisher.Mono<StudioWebSocketClient.UserInputData> waitForInput(String requestId) Waits for user input matching the given request ID.This method is called after sending a requestUserInput HTTP request. It returns a Mono that will emit when the corresponding forwardUserInput event arrives via WebSocket.
- Parameters:
requestId- The request ID to wait for (from StudioClient.requestUserInput)- Returns:
- A Mono that emits the user input data when available
-
close
public void close()Closes the WebSocket connection and releases resources. -
isConnected
public boolean isConnected()Checks if the WebSocket is currently connected.- Returns:
- true if connected, false otherwise
-