类 WebSocketSessionDecorator
- java.lang.Object
- org.springframework.web.socket.handler.WebSocketSessionDecorator
- 所有已实现的接口:
Closeable
,AutoCloseable
,WebSocketSession
public class WebSocketSessionDecorator extends Object implements WebSocketSession
Wraps anotherWebSocketSession
instance and delegates to it.Also provides a
getDelegate()
method to return the decorated session as well as agetLastSession()
method to go through all nested delegates and return the "last" session.- 从以下版本开始:
- 4.0.3
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 构造器 说明 WebSocketSessionDecorator(WebSocketSession session)
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 void
close()
Close the WebSocket connection with status 1000, i.e. equivalent to:void
close(CloseStatus status)
Close the WebSocket connection with the given close status.String
getAcceptedProtocol()
Return the negotiated sub-protocol.Map<String,Object>
getAttributes()
Return the map with attributes associated with the WebSocket session.int
getBinaryMessageSizeLimit()
Get the configured maximum size for an incoming binary message.WebSocketSession
getDelegate()
List<WebSocketExtension>
getExtensions()
Determine the negotiated extensions.HttpHeaders
getHandshakeHeaders()
Return the headers used in the handshake request (nevernull
).String
getId()
Return a unique session identifier.WebSocketSession
getLastSession()
InetSocketAddress
getLocalAddress()
Return the address on which the request was received.Principal
getPrincipal()
Return aPrincipal
instance containing the name of the authenticated user.InetSocketAddress
getRemoteAddress()
Return the address of the remote client.int
getTextMessageSizeLimit()
Get the configured maximum size for an incoming text message.URI
getUri()
Return the URI used to open the WebSocket connection.boolean
isOpen()
Return whether the connection is still open.void
sendMessage(WebSocketMessage<?> message)
Send a WebSocket message: eitherTextMessage
orBinaryMessage
.void
setBinaryMessageSizeLimit(int messageSizeLimit)
Configure the maximum size for an incoming binary message.void
setTextMessageSizeLimit(int messageSizeLimit)
Configure the maximum size for an incoming text message.String
toString()
static WebSocketSession
unwrap(WebSocketSession session)
构造器详细资料
WebSocketSessionDecorator
public WebSocketSessionDecorator(WebSocketSession session)
方法详细资料
getDelegate
public WebSocketSession getDelegate()
getLastSession
public WebSocketSession getLastSession()
unwrap
public static WebSocketSession unwrap(WebSocketSession session)
getId
public String getId()
从接口复制的说明:WebSocketSession
Return a unique session identifier.- 指定者:
getId
在接口中WebSocketSession
getUri
public URI getUri()
从接口复制的说明:WebSocketSession
Return the URI used to open the WebSocket connection.- 指定者:
getUri
在接口中WebSocketSession
getHandshakeHeaders
public HttpHeaders getHandshakeHeaders()
从接口复制的说明:WebSocketSession
Return the headers used in the handshake request (nevernull
).- 指定者:
getHandshakeHeaders
在接口中WebSocketSession
getAttributes
public Map<String,Object> getAttributes()
从接口复制的说明:WebSocketSession
Return the map with attributes associated with the WebSocket session.On the server side the map can be populated initially through a
HandshakeInterceptor
. On the client side the map can be populated viaWebSocketClient
handshake methods.- 指定者:
getAttributes
在接口中WebSocketSession
- 返回:
- a Map with the session attributes (never
null
)
getPrincipal
public Principal getPrincipal()
从接口复制的说明:WebSocketSession
Return aPrincipal
instance containing the name of the authenticated user.If the user has not been authenticated, the method returns
null
.- 指定者:
getPrincipal
在接口中WebSocketSession
getLocalAddress
public InetSocketAddress getLocalAddress()
从接口复制的说明:WebSocketSession
Return the address on which the request was received.- 指定者:
getLocalAddress
在接口中WebSocketSession
getRemoteAddress
public InetSocketAddress getRemoteAddress()
从接口复制的说明:WebSocketSession
Return the address of the remote client.- 指定者:
getRemoteAddress
在接口中WebSocketSession
getAcceptedProtocol
public String getAcceptedProtocol()
从接口复制的说明:WebSocketSession
Return the negotiated sub-protocol.- 指定者:
getAcceptedProtocol
在接口中WebSocketSession
- 返回:
- the protocol identifier, or
null
if no protocol was specified or negotiated successfully
getExtensions
public List<WebSocketExtension> getExtensions()
从接口复制的说明:WebSocketSession
Determine the negotiated extensions.- 指定者:
getExtensions
在接口中WebSocketSession
- 返回:
- the list of extensions, or an empty list if no extension was specified or negotiated successfully
setTextMessageSizeLimit
public void setTextMessageSizeLimit(int messageSizeLimit)
从接口复制的说明:WebSocketSession
Configure the maximum size for an incoming text message.- 指定者:
setTextMessageSizeLimit
在接口中WebSocketSession
getTextMessageSizeLimit
public int getTextMessageSizeLimit()
从接口复制的说明:WebSocketSession
Get the configured maximum size for an incoming text message.- 指定者:
getTextMessageSizeLimit
在接口中WebSocketSession
setBinaryMessageSizeLimit
public void setBinaryMessageSizeLimit(int messageSizeLimit)
从接口复制的说明:WebSocketSession
Configure the maximum size for an incoming binary message.
getBinaryMessageSizeLimit
public int getBinaryMessageSizeLimit()
从接口复制的说明:WebSocketSession
Get the configured maximum size for an incoming binary message.
isOpen
public boolean isOpen()
从接口复制的说明:WebSocketSession
Return whether the connection is still open.- 指定者:
isOpen
在接口中WebSocketSession
sendMessage
public void sendMessage(WebSocketMessage<?> message) throws IOException
从接口复制的说明:WebSocketSession
Send a WebSocket message: eitherTextMessage
orBinaryMessage
.Note: The underlying standard WebSocket session (JSR-356) does not allow concurrent sending. Therefore sending must be synchronized. To ensure that, one option is to wrap the
WebSocketSession
with theConcurrentWebSocketSessionDecorator
.
close
public void close() throws IOException
从接口复制的说明:WebSocketSession
Close the WebSocket connection with status 1000, i.e. equivalent to:session.close(CloseStatus.NORMAL);
- 指定者:
close
在接口中AutoCloseable
- 指定者:
close
在接口中Closeable
- 指定者:
close
在接口中WebSocketSession
- 抛出:
IOException
close
public void close(CloseStatus status) throws IOException
从接口复制的说明:WebSocketSession
Close the WebSocket connection with the given close status.- 指定者:
close
在接口中WebSocketSession
- 抛出:
IOException