Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
WebSocketService
interface (line#5368)
Motivation: `WebsocketService` is a final class, so it is not easy to make another service run WebSocket and HTTP requests on the same path. `WebSocketService` is changed as a marker interface in line#5280. However, the interface does not have API, the service cannot take advantage of the protocol detection of the original `WebSocketService`. Graphql WebSocket implementation copied and pasted similar code for WebSocket detection. The design of the code here was determined after discussions with other maintainers based on the idea from line#5280 (comment) Modifications: - Add `WebSocketService` interface and rename the original one to `DefaultWebSocketService` - Add `WebSocketProtocolHandler` that is in charge of: - Upgrade HTTP request to WebSocket - Decode HTTP request to WebSocket for inbound - Encode WebSocket to HTTP response for outbound - Refactor `DefaultWebSocketService` to implement new methods `WebSocketService` and `WebSocketProtocolHandler` - Modify Webservicebuilder so that a fallback service can be configured. - The fallback service would be useful when WebSocket and HTTP request is served at the same path. Result: - You can now set a fallback service to `WebSocketService` via `WebSocketServiceBuilder.fallbackService()` - Refactor `WebsocketService` to enable composion and delegatation.
- Loading branch information