Class CopilotWebSocketHandler
java.lang.Object
com.github.copilot.CopilotWebSocketHandler
- All Implemented Interfaces:
AutoCloseable
- Direct Known Subclasses:
CopilotWebSocketForwarder
A per-connection WebSocket handler returned by
CopilotRequestHandler.openWebSocket(CopilotRequestContext).
The default implementation is CopilotWebSocketForwarder, which dials
the real upstream and transparently relays messages in both directions. A
full transport replacement subclasses this type directly and brings its own
transport and receive loop, forwarding upstream-to-runtime messages by
calling sendResponseMessage(CopilotWebSocketMessage) and finishing with
close(CopilotWebSocketCloseStatus).
- Since:
- 1.0.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CopilotRequestContextThe request context for this WebSocket connection. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedInitializes a per-connection handler for the supplied request context. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Tears down the connection, finalising with a normal closure unless the connection has already been closed or close-on-dispose was suppressed.voidclose(CopilotWebSocketCloseStatus status) Closes the connection and finalises the runtime-facing response.abstract voidSends a message from the runtime to the upstream connection.voidSends a message from the upstream connection back to the runtime.
-
Field Details
-
context
The request context for this WebSocket connection.
-
-
Constructor Details
-
CopilotWebSocketHandler
Initializes a per-connection handler for the supplied request context.- Parameters:
context- the per-request context
-
-
Method Details
-
sendRequestMessage
Sends a message from the runtime to the upstream connection.- Parameters:
message- the message to forward upstream- Throws:
Exception- if the message could not be forwarded
-
sendResponseMessage
Sends a message from the upstream connection back to the runtime. Override to mutate or duplicate messages; callsuperto emit.- Parameters:
message- the upstream-to-runtime message- Throws:
Exception- if the message could not be delivered
-
close
Closes the connection and finalises the runtime-facing response. Idempotent.- Parameters:
status- the terminal status; a non-nullCopilotWebSocketCloseStatus.error()surfaces a transport failure, otherwise a clean end-of-stream- Throws:
Exception- if the terminal frame could not be delivered
-
close
public void close()Tears down the connection, finalising with a normal closure unless the connection has already been closed or close-on-dispose was suppressed.- Specified by:
closein interfaceAutoCloseable
-