Top Description Fields Constructors Methods
org.springframework.web.socket.client

public Class WebSocketConnectionManager

extends ConnectionManagerSupport
Class Inheritance
Imports
java.net.URI, java.util.List, java.util.concurrent.CompletableFuture, org.springframework.context.Lifecycle, org.springframework.http.HttpHeaders, org.springframework.lang.Nullable, org.springframework.web.socket.WebSocketHandler, .WebSocketHttpHeaders, .WebSocketSession, org.springframework.web.socket.handler.LoggingWebSocketHandlerDecorator

WebSocket connection manager that connects to the server via WebSocketClient and handles the session with a WebSocketHandler.
Authors
Rossen Stoyanchev, Sam Brannen
Since
4.0

Field Summary

Modifier and TypeField and Description
private final WebSocketClient
private final WebSocketHttpHeaders
private final WebSocketHandler
private WebSocketSession
Inherited from org.springframework.web.socket.client.ConnectionManagerSupport:
logger

Constructor Summary

AccessConstructor and Description
public
WebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVariables)

Constructor with the client to use and a handler to handle messages with.

public

Method Summary

Modifier and TypeMethod and Description
protected void
closeConnection()

Implements abstract org.springframework.web.socket.client.ConnectionManagerSupport.closeConnection.

Subclasses implement this to close the connection.

protected WebSocketHandler
decorateWebSocketHandler(WebSocketHandler handler)

Decorate the WebSocketHandler provided to the class constructor.

public HttpHeaders
getHeaders()

Return the default headers for the WebSocket handshake request.

public String
getOrigin()

Return the configured origin.

public List<String>
getSubProtocols()

Return the configured sub-protocols to use.

public boolean
isConnected()

Implements abstract org.springframework.web.socket.client.ConnectionManagerSupport.isConnected.

Whether the connection is open/true or closed/false.

protected void
openConnection()

Implements abstract org.springframework.web.socket.client.ConnectionManagerSupport.openConnection.

Subclasses implement this to actually establish the connection.

public void
setHeaders(HttpHeaders headers)

Provide default headers to add to the WebSocket handshake request.

public void
setOrigin(String origin)

Set the origin to use.

public void
setSubProtocols(List<String> protocols)

Set the sub-protocols to use.

public void
public void
Inherited from org.springframework.web.socket.client.ConnectionManagerSupport:
getPhasegetUriisAutoStartupisRunningsetAutoStartupsetPhasestartstopstop

Field Detail

clientback to summary
private final WebSocketClient client
headersback to summary
private final WebSocketHttpHeaders headers
webSocketHandlerback to summary
private final WebSocketHandler webSocketHandler
webSocketSessionback to summary
private WebSocketSession webSocketSession
Annotations
@Nullable

Constructor Detail

WebSocketConnectionManagerback to summary
public WebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, String uriTemplate, Object... uriVariables)

Constructor with the client to use and a handler to handle messages with.

WebSocketConnectionManagerback to summary
public WebSocketConnectionManager(WebSocketClient client, WebSocketHandler webSocketHandler, URI uri)

Variant of WebSocketConnectionManager(WebSocketClient, WebSocketHandler, String, Object...) with a prepared URI.

Since
6.0.5

Method Detail

closeConnectionback to summary
protected void closeConnection() throws Exception

Implements abstract org.springframework.web.socket.client.ConnectionManagerSupport.closeConnection.

Doc from org.springframework.web.socket.client.ConnectionManagerSupport.closeConnection.

Subclasses implement this to close the connection.

Annotations
@Override
decorateWebSocketHandlerback to summary
protected WebSocketHandler decorateWebSocketHandler(WebSocketHandler handler)

Decorate the WebSocketHandler provided to the class constructor.

By default LoggingWebSocketHandlerDecorator is added.

getHeadersback to summary
public HttpHeaders getHeaders()

Return the default headers for the WebSocket handshake request.

getOriginback to summary
public String getOrigin()

Return the configured origin.

Annotations
@Nullable
getSubProtocolsback to summary
public List<String> getSubProtocols()

Return the configured sub-protocols to use.

isConnectedback to summary
public boolean isConnected()

Implements abstract org.springframework.web.socket.client.ConnectionManagerSupport.isConnected.

Doc from org.springframework.web.socket.client.ConnectionManagerSupport.isConnected.

Whether the connection is open/true or closed/false.

Annotations
@Override
openConnectionback to summary
protected void openConnection()

Implements abstract org.springframework.web.socket.client.ConnectionManagerSupport.openConnection.

Doc from org.springframework.web.socket.client.ConnectionManagerSupport.openConnection.

Subclasses implement this to actually establish the connection.

Annotations
@Override
setHeadersback to summary
public void setHeaders(HttpHeaders headers)

Provide default headers to add to the WebSocket handshake request.

setOriginback to summary
public void setOrigin(String origin)

Set the origin to use.

setSubProtocolsback to summary
public void setSubProtocols(List<String> protocols)

Set the sub-protocols to use. If configured, specified sub-protocols will be requested in the handshake through the Sec-WebSocket-Protocol header. The resulting WebSocket session will contain the protocol accepted by the server, if any.

startInternalback to summary
public void startInternal()

Overrides org.springframework.web.socket.client.ConnectionManagerSupport.startInternal.

Annotations
@Override
stopInternalback to summary
public void stopInternal() throws Exception

Overrides org.springframework.web.socket.client.ConnectionManagerSupport.stopInternal.

Annotations
@Override