Skip to content

Commit

Permalink
Fix issue-211 - Add method for use by front controller
Browse files Browse the repository at this point in the history
  • Loading branch information
markt-asf committed Oct 7, 2021
1 parent 7b1bca6 commit 9a745c2
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@

package jakarta.websocket.server;

import java.io.IOException;
import java.util.Map;

import jakarta.websocket.*;

/**
Expand Down Expand Up @@ -59,4 +62,30 @@ public interface ServerContainer extends WebSocketContainer {
*/
public void addEndpoint(ServerEndpointConfig serverConfig) throws DeploymentException;

/**
* Upgrade the HTTP connection represented by the {@code HttpServletRequest} and {@code HttpServletResponse} to the
* WebSocket protocol and establish a WebSocket connection as per the provided {@link ServerEndpointConfig}.
* <p>
* This method is primarily intended to be used by frameworks that implement the front-controller pattern.
* <p>
* If the WebSocket implementation is not deployed as part of a Jakarta Servlet container, this method will throw an
* {@link UnsupportedOperationException}.
*
* @param httpServletRequest The {@code HttpServletRequest} to be processed as a WebSocket handshake as per
* section 4.0 of RFC 6455.
* @param httpServletResponse The {@code HttpServletResponse} to be used when processing the
* {@code httpServletRequest} as a WebSocket handshake as per section 4.0 of RFC 6455.
* @param sec The server endpoint configuration to use to configure the WebSocket endpoint
* @param pathParameters Provides a mapping of path parameter names and values, if any, to be used for the
* WebSocket connection established by the call to this method. If no such mapping is
* defined, an empty Map must be passed.
*
* @throws IllegalStateException if the provided request does not meet the requirements of the WebSocket handshake
* @throws UnsupportedOperationException if the WebSocket implementation is not deployed as part of a Jakarta
* Servlet container
* @throws IOException if an I/O error occurs during the establishment of a WebSocket connection
* @throws DeploymentException if a configuration error prevents the establishment of a WebSocket connection
*/
public void upgradeHttpToWebSocket(Object httpServletRequest, Object httpServletResponse, ServerEndpointConfig sec,
Map<String,String> pathParameters) throws IOException, DeploymentException;
}

0 comments on commit 9a745c2

Please sign in to comment.