Class CopilotWebSocketForwarder
java.lang.Object
com.github.copilot.CopilotWebSocketHandler
com.github.copilot.CopilotWebSocketForwarder
- All Implemented Interfaces:
AutoCloseable
The default pass-through
CopilotWebSocketHandler: it dials the real
upstream using WebSocket and relays upstream-to-runtime
messages into the runtime response unchanged.
Subclass and override sendRequestMessage(CopilotWebSocketMessage) or
CopilotWebSocketHandler.sendResponseMessage(CopilotWebSocketMessage) (calling super) to observe, transform,
or drop messages in either direction.
- Since:
- 1.0.0
-
Field Summary
Fields inherited from class CopilotWebSocketHandler
context -
Constructor Summary
ConstructorsConstructorDescriptionCreates a forwarding handler targeting the request URL and headers fromcontext. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose(CopilotWebSocketCloseStatus status) Closes the connection and finalises the runtime-facing response.voidSends a message from the runtime to the upstream connection.Methods inherited from class CopilotWebSocketHandler
close, sendResponseMessage
-
Constructor Details
-
CopilotWebSocketForwarder
Creates a forwarding handler targeting the request URL and headers fromcontext.- Parameters:
context- the per-request context
-
-
Method Details
-
sendRequestMessage
Description copied from class:CopilotWebSocketHandlerSends a message from the runtime to the upstream connection.- Specified by:
sendRequestMessagein classCopilotWebSocketHandler- Parameters:
message- the message to forward upstream- Throws:
Exception- if the message could not be forwarded
-
close
Description copied from class:CopilotWebSocketHandlerCloses the connection and finalises the runtime-facing response. Idempotent.- Overrides:
closein classCopilotWebSocketHandler- 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
-