类 WebSocketServerSockJsSession
- java.lang.Object
- org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession
- org.springframework.web.socket.sockjs.transport.session.WebSocketServerSockJsSession
public class WebSocketServerSockJsSession extends AbstractSockJsSession implements NativeWebSocketSession
A SockJS session for use with the WebSocket transport.- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev, Juergen Hoeller
字段概要
从类继承的字段 org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession
DISCONNECTED_CLIENT_LOG_CATEGORY, disconnectedClientLogger, logger, responseLock
构造器概要
构造器 构造器 说明 WebSocketServerSockJsSession(String id, SockJsServiceConfig config, WebSocketHandler handler, Map<String,Object> attributes)
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected void
disconnect(CloseStatus status)
Actually close the underlying WebSocket session or in the case of HTTP transports complete the underlying request.String
getAcceptedProtocol()
Return the negotiated sub-protocol.int
getBinaryMessageSizeLimit()
Get the configured maximum size for an incoming binary message.List<WebSocketExtension>
getExtensions()
Determine the negotiated extensions.HttpHeaders
getHandshakeHeaders()
Return the headers used in the handshake request (nevernull
).InetSocketAddress
getLocalAddress()
Return the address on which the request was received.Object
getNativeSession()
Return the underlying native WebSocketSession.<T> T
getNativeSession(Class<T> requiredType)
Return the underlying native WebSocketSession, if available.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.void
handleMessage(TextMessage message, WebSocketSession wsSession)
void
initializeDelegateSession(WebSocketSession session)
boolean
isActive()
Polling and Streaming sessions periodically close the current HTTP request and wait for the next request to come through.void
sendMessageInternal(String message)
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.protected void
writeFrameInternal(SockJsFrame frame)
从类继承的方法 org.springframework.web.socket.sockjs.transport.session.AbstractSockJsSession
cancelHeartbeat, close, close, delegateConnectionClosed, delegateConnectionEstablished, delegateError, delegateMessages, disableHeartbeat, getAttributes, getId, getMessageCodec, getSockJsServiceConfig, getTimeSinceLastActive, isClosed, isNew, isOpen, scheduleHeartbeat, sendHeartbeat, sendMessage, toString, tryCloseWithSockJsTransportError, updateLastActiveTime, writeFrame
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从接口继承的方法 org.springframework.web.socket.WebSocketSession
close, close, getAttributes, getId, isOpen, sendMessage
构造器详细资料
WebSocketServerSockJsSession
public WebSocketServerSockJsSession(String id, SockJsServiceConfig config, WebSocketHandler handler, Map<String,Object> attributes)
方法详细资料
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
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
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.
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
getNativeSession
public Object getNativeSession()
从接口复制的说明:NativeWebSocketSession
Return the underlying native WebSocketSession.- 指定者:
getNativeSession
在接口中NativeWebSocketSession
getNativeSession
public <T> T getNativeSession(Class<T> requiredType)
从接口复制的说明:NativeWebSocketSession
Return the underlying native WebSocketSession, if available.- 指定者:
getNativeSession
在接口中NativeWebSocketSession
- 参数:
requiredType
- the required type of the session- 返回:
- the native session of the required type, or
null
if not available
initializeDelegateSession
public void initializeDelegateSession(WebSocketSession session)
isActive
public boolean isActive()
从类复制的说明:AbstractSockJsSession
Polling and Streaming sessions periodically close the current HTTP request and wait for the next request to come through. During this "downtime" the session is still open but inactive and unable to send messages and therefore has to buffer them temporarily. A WebSocket session by contrast is stateful and remain active until closed.- 指定者:
isActive
在类中AbstractSockJsSession
handleMessage
public void handleMessage(TextMessage message, WebSocketSession wsSession) throws Exception
- 抛出:
Exception
sendMessageInternal
public void sendMessageInternal(String message) throws SockJsTransportFailureException
writeFrameInternal
protected void writeFrameInternal(SockJsFrame frame) throws IOException
disconnect
protected void disconnect(CloseStatus status) throws IOException
从类复制的说明:AbstractSockJsSession
Actually close the underlying WebSocket session or in the case of HTTP transports complete the underlying request.- 指定者:
disconnect
在类中AbstractSockJsSession
- 抛出:
IOException