Top Description Inners Fields Constructors Methods
org.springframework.web.socket.adapter.jetty

public Class JettyWebSocketSession

extends AbstractWebSocketSession<Session>
Class Inheritance
Imports
java.io.IOException, .UncheckedIOException, java.net.InetSocketAddress, .URI, java.security.Principal, java.util.ArrayList, .Collections, .List, .Map, java.util.concurrent.ExecutionException, org.eclipse.jetty.websocket.api.Callback, .ExtensionConfig, .Session, org.springframework.http.HttpHeaders, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, org.springframework.web.socket.BinaryMessage, .CloseStatus, .PingMessage, .PongMessage, .TextMessage, .WebSocketExtension, .WebSocketSession, org.springframework.web.socket.adapter.AbstractWebSocketSession

A WebSocketSession for use with the Jetty WebSocket API.
Authors
Phillip Webb, Rossen Stoyanchev, Brian Clozel, Juergen Hoeller
Since
4.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static interface

Field Summary

Modifier and TypeField and Description
private String
private List<WebSocketExtension>
private HttpHeaders
private final String
private URI
private Principal
Inherited from org.springframework.web.socket.adapter.AbstractWebSocketSession:
idGeneratorlogger

Constructor Summary

AccessConstructor and Description
public
JettyWebSocketSession(Map<String, Object>
the attributes from the HTTP handshake to associate with the WebSocket session
attributes
)

Create a new JettyWebSocketSession instance.

public
JettyWebSocketSession(Map<String, Object>
the attributes from the HTTP handshake to associate with the WebSocket session; the provided attributes are copied, the original map is not used.
attributes
,
Principal
the user associated with the session; if null we'll fall back on the user available via org.eclipse.jetty.websocket.api.Session#getUpgradeRequest()
user
)

Create a new JettyWebSocketSession instance associated with the given user.

Method Summary

Modifier and TypeMethod and Description
protected void
public String
public int
getBinaryMessageSizeLimit()

Implements org.springframework.web.socket.WebSocketSession.getBinaryMessageSizeLimit.

Get the configured maximum size for an incoming binary message.

public List<WebSocketExtension>
getExtensions()

Implements org.springframework.web.socket.WebSocketSession.getExtensions.

Determine the negotiated extensions.

private List<WebSocketExtension>
public HttpHeaders
getHandshakeHeaders()

Implements org.springframework.web.socket.WebSocketSession.getHandshakeHeaders.

Return the headers used in the handshake request (never null).

public String
getId()

Implements org.springframework.web.socket.WebSocketSession.getId.

Return a unique session identifier.

public InetSocketAddress
getLocalAddress()

Implements org.springframework.web.socket.WebSocketSession.getLocalAddress.

Return the address on which the request was received.

public Principal
getPrincipal()

Implements org.springframework.web.socket.WebSocketSession.getPrincipal.

Return a java.security.Principal instance containing the name of the authenticated user.

public InetSocketAddress
getRemoteAddress()

Implements org.springframework.web.socket.WebSocketSession.getRemoteAddress.

Return the address of the remote client.

public int
getTextMessageSizeLimit()

Implements org.springframework.web.socket.WebSocketSession.getTextMessageSizeLimit.

Get the configured maximum size for an incoming text message.

public URI
getUri()

Implements org.springframework.web.socket.WebSocketSession.getUri.

Return the URI used to open the WebSocket connection.

public void
public boolean
isOpen()

Implements org.springframework.web.socket.WebSocketSession.isOpen.

Whether the underlying connection is open.

protected void
protected void
protected void
protected void
public void
setBinaryMessageSizeLimit(int messageSizeLimit)

Implements org.springframework.web.socket.WebSocketSession.setBinaryMessageSizeLimit.

Configure the maximum size for an incoming binary message.

public void
setTextMessageSizeLimit(int messageSizeLimit)

Implements org.springframework.web.socket.WebSocketSession.setTextMessageSizeLimit.

Configure the maximum size for an incoming text message.

private void
Inherited from org.springframework.web.socket.adapter.AbstractWebSocketSession:
checkNativeSessionInitializedcloseclosegetAttributesgetNativeSessiongetNativeSessionsendMessagetoString

Field Detail

acceptedProtocolback to summary
private String acceptedProtocol
Annotations
@Nullable
extensionsback to summary
private List<WebSocketExtension> extensions
Annotations
@Nullable
headersback to summary
private HttpHeaders headers
Annotations
@Nullable
idback to summary
private final String id
uriback to summary
private URI uri
Annotations
@Nullable
userback to summary
private Principal user
Annotations
@Nullable

Constructor Detail

JettyWebSocketSessionback to summary
public JettyWebSocketSession(Map<String, Object> attributes)

Create a new JettyWebSocketSession instance.

Parameters
attributes:Map<String, Object>

the attributes from the HTTP handshake to associate with the WebSocket session

JettyWebSocketSessionback to summary
public JettyWebSocketSession(Map<String, Object> attributes, Principal user)

Create a new JettyWebSocketSession instance associated with the given user.

Parameters
attributes:Map<String, Object>

the attributes from the HTTP handshake to associate with the WebSocket session; the provided attributes are copied, the original map is not used.

user:Principal

the user associated with the session; if null we'll fall back on the user available via org.eclipse.jetty.websocket.api.Session#getUpgradeRequest()

Method Detail

closeInternalback to summary
protected void closeInternal(CloseStatus status) throws IOException

Implements abstract org.springframework.web.socket.adapter.AbstractWebSocketSession.closeInternal.

Annotations
@Override
getAcceptedProtocolback to summary
public String getAcceptedProtocol()

Implements org.springframework.web.socket.WebSocketSession.getAcceptedProtocol.

Doc from org.springframework.web.socket.WebSocketSession.getAcceptedProtocol.

Return the negotiated sub-protocol.

Returns:String

the protocol identifier, or null if no protocol was specified or negotiated successfully

Annotations
@Override
getBinaryMessageSizeLimitback to summary
public int getBinaryMessageSizeLimit()

Implements org.springframework.web.socket.WebSocketSession.getBinaryMessageSizeLimit.

Doc from org.springframework.web.socket.WebSocketSession.getBinaryMessageSizeLimit.

Get the configured maximum size for an incoming binary message.

Annotations
@Override
getExtensionsback to summary
public List<WebSocketExtension> getExtensions()

Implements org.springframework.web.socket.WebSocketSession.getExtensions.

Doc from org.springframework.web.socket.WebSocketSession.getExtensions.

Determine the negotiated extensions.

Returns:List<WebSocketExtension>

the list of extensions, or an empty list if no extension was specified or negotiated successfully

Annotations
@Override
getExtensionsback to summary
private List<WebSocketExtension> getExtensions(Session session)
getHandshakeHeadersback to summary
public HttpHeaders getHandshakeHeaders()

Implements org.springframework.web.socket.WebSocketSession.getHandshakeHeaders.

Doc from org.springframework.web.socket.WebSocketSession.getHandshakeHeaders.

Return the headers used in the handshake request (never null).

Annotations
@Override
getIdback to summary
public String getId()

Implements org.springframework.web.socket.WebSocketSession.getId.

Doc from org.springframework.web.socket.WebSocketSession.getId.

Return a unique session identifier.

Annotations
@Override
getLocalAddressback to summary
public InetSocketAddress getLocalAddress()

Implements org.springframework.web.socket.WebSocketSession.getLocalAddress.

Doc from org.springframework.web.socket.WebSocketSession.getLocalAddress.

Return the address on which the request was received.

Annotations
@Override
getPrincipalback to summary
public Principal getPrincipal()

Implements org.springframework.web.socket.WebSocketSession.getPrincipal.

Doc from org.springframework.web.socket.WebSocketSession.getPrincipal.

Return a java.security.Principal instance containing the name of the authenticated user.

If the user has not been authenticated, the method returns null.

Annotations
@Override
getRemoteAddressback to summary
public InetSocketAddress getRemoteAddress()

Implements org.springframework.web.socket.WebSocketSession.getRemoteAddress.

Doc from org.springframework.web.socket.WebSocketSession.getRemoteAddress.

Return the address of the remote client.

Annotations
@Override
getTextMessageSizeLimitback to summary
public int getTextMessageSizeLimit()

Implements org.springframework.web.socket.WebSocketSession.getTextMessageSizeLimit.

Doc from org.springframework.web.socket.WebSocketSession.getTextMessageSizeLimit.

Get the configured maximum size for an incoming text message.

Annotations
@Override
getUriback to summary
public URI getUri()

Implements org.springframework.web.socket.WebSocketSession.getUri.

Doc from org.springframework.web.socket.WebSocketSession.getUri.

Return the URI used to open the WebSocket connection.

Annotations
@Override
@Nullable
initializeNativeSessionback to summary
public void initializeNativeSession(Session session)

Overrides org.springframework.web.socket.adapter.AbstractWebSocketSession.initializeNativeSession.

Annotations
@Override
isOpenback to summary
public boolean isOpen()

Implements org.springframework.web.socket.WebSocketSession.isOpen.

Doc from org.springframework.web.socket.WebSocketSession.isOpen.

Whether the underlying connection is open.

Annotations
@Override
sendBinaryMessageback to summary
protected void sendBinaryMessage(BinaryMessage message) throws IOException

Implements abstract org.springframework.web.socket.adapter.AbstractWebSocketSession.sendBinaryMessage.

Annotations
@Override
sendPingMessageback to summary
protected void sendPingMessage(PingMessage message) throws IOException

Implements abstract org.springframework.web.socket.adapter.AbstractWebSocketSession.sendPingMessage.

Annotations
@Override
sendPongMessageback to summary
protected void sendPongMessage(PongMessage message) throws IOException

Implements abstract org.springframework.web.socket.adapter.AbstractWebSocketSession.sendPongMessage.

Annotations
@Override
sendTextMessageback to summary
protected void sendTextMessage(TextMessage message) throws IOException

Implements abstract org.springframework.web.socket.adapter.AbstractWebSocketSession.sendTextMessage.

Annotations
@Override
setBinaryMessageSizeLimitback to summary
public void setBinaryMessageSizeLimit(int messageSizeLimit)

Implements org.springframework.web.socket.WebSocketSession.setBinaryMessageSizeLimit.

Doc from org.springframework.web.socket.WebSocketSession.setBinaryMessageSizeLimit.

Configure the maximum size for an incoming binary message.

Annotations
@Override
setTextMessageSizeLimitback to summary
public void setTextMessageSizeLimit(int messageSizeLimit)

Implements org.springframework.web.socket.WebSocketSession.setTextMessageSizeLimit.

Doc from org.springframework.web.socket.WebSocketSession.setTextMessageSizeLimit.

Configure the maximum size for an incoming text message.

Annotations
@Override
useSessionback to summary
private void useSession(JettyWebSocketSession.SessionConsumer sessionConsumer) throws IOException
org.springframework.web.socket.adapter.jetty back to summary

private Interface JettyWebSocketSession.SessionConsumer

Annotations
@FunctionalInterface

Method Summary

Modifier and TypeMethod and Description
public void
consume(Session session, Callback callback)

Method Detail

consumeback to summary
public void consume(Session session, Callback callback) throws IOException