类 JettyWebSocketSession
- java.lang.Object
- org.springframework.web.socket.adapter.AbstractWebSocketSession<org.eclipse.jetty.websocket.api.Session>
- org.springframework.web.socket.adapter.jetty.JettyWebSocketSession
- 所有已实现的接口:
Closeable
,AutoCloseable
,NativeWebSocketSession
,WebSocketSession
public class JettyWebSocketSession extends AbstractWebSocketSession<org.eclipse.jetty.websocket.api.Session>
AWebSocketSession
for use with the Jetty 9.3/9.4 WebSocket API.- 从以下版本开始:
- 4.0
- 作者:
- Phillip Webb, Rossen Stoyanchev, Brian Clozel, Juergen Hoeller
字段概要
从类继承的字段 org.springframework.web.socket.adapter.AbstractWebSocketSession
logger
构造器概要
构造器 构造器 说明 JettyWebSocketSession(Map<String,Object> attributes)
Create a newJettyWebSocketSession
instance.JettyWebSocketSession(Map<String,Object> attributes, Principal user)
Create a newJettyWebSocketSession
instance associated with the given user.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 protected void
closeInternal(CloseStatus status)
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
).String
getId()
Return a unique session identifier.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.void
initializeNativeSession(org.eclipse.jetty.websocket.api.Session session)
boolean
isOpen()
Return whether the connection is still open.protected void
sendBinaryMessage(BinaryMessage message)
protected void
sendPingMessage(PingMessage message)
protected void
sendPongMessage(PongMessage message)
protected void
sendTextMessage(TextMessage 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.从类继承的方法 org.springframework.web.socket.adapter.AbstractWebSocketSession
checkNativeSessionInitialized, close, close, getAttributes, getNativeSession, getNativeSession, sendMessage, toString
构造器详细资料
JettyWebSocketSession
public JettyWebSocketSession(Map<String,Object> attributes)
Create a newJettyWebSocketSession
instance.- 参数:
attributes
- attributes from the HTTP handshake to associate with the WebSocket session
JettyWebSocketSession
public JettyWebSocketSession(Map<String,Object> attributes, Principal user)
Create a newJettyWebSocketSession
instance associated with the given user.- 参数:
attributes
- attributes from the HTTP handshake to associate with the WebSocket session; the provided attributes are copied, the original map is not used.user
- the user associated with the session; ifnull
we'll fallback on the user available viaSession.getUpgradeRequest()
方法详细资料
getId
public String getId()
从接口复制的说明:WebSocketSession
Return a unique session identifier.
getUri
public URI getUri()
从接口复制的说明:WebSocketSession
Return the URI used to open the WebSocket connection.
getHandshakeHeaders
public HttpHeaders getHandshakeHeaders()
从接口复制的说明:WebSocketSession
Return the headers used in the handshake request (nevernull
).
getAcceptedProtocol
public String getAcceptedProtocol()
从接口复制的说明:WebSocketSession
Return the negotiated sub-protocol.- 返回:
- the protocol identifier, or
null
if no protocol was specified or negotiated successfully
getExtensions
public List<WebSocketExtension> getExtensions()
从接口复制的说明:WebSocketSession
Determine the negotiated extensions.- 返回:
- the list of extensions, or an empty list if no extension was specified or negotiated successfully
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
.
getLocalAddress
public InetSocketAddress getLocalAddress()
从接口复制的说明:WebSocketSession
Return the address on which the request was received.
getRemoteAddress
public InetSocketAddress getRemoteAddress()
从接口复制的说明:WebSocketSession
Return the address of the remote client.
setTextMessageSizeLimit
public void setTextMessageSizeLimit(int messageSizeLimit)
从接口复制的说明:WebSocketSession
Configure the maximum size for an incoming text message.
getTextMessageSizeLimit
public int getTextMessageSizeLimit()
从接口复制的说明:WebSocketSession
Get the configured maximum size for an incoming text message.
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.
initializeNativeSession
public void initializeNativeSession(org.eclipse.jetty.websocket.api.Session session)
- 覆盖:
initializeNativeSession
在类中AbstractWebSocketSession<org.eclipse.jetty.websocket.api.Session>
sendTextMessage
protected void sendTextMessage(TextMessage message) throws IOException
- 指定者:
sendTextMessage
在类中AbstractWebSocketSession<org.eclipse.jetty.websocket.api.Session>
- 抛出:
IOException
sendBinaryMessage
protected void sendBinaryMessage(BinaryMessage message) throws IOException
- 指定者:
sendBinaryMessage
在类中AbstractWebSocketSession<org.eclipse.jetty.websocket.api.Session>
- 抛出:
IOException
sendPingMessage
protected void sendPingMessage(PingMessage message) throws IOException
- 指定者:
sendPingMessage
在类中AbstractWebSocketSession<org.eclipse.jetty.websocket.api.Session>
- 抛出:
IOException
sendPongMessage
protected void sendPongMessage(PongMessage message) throws IOException
- 指定者:
sendPongMessage
在类中AbstractWebSocketSession<org.eclipse.jetty.websocket.api.Session>
- 抛出:
IOException
closeInternal
protected void closeInternal(CloseStatus status) throws IOException
- 指定者:
closeInternal
在类中AbstractWebSocketSession<org.eclipse.jetty.websocket.api.Session>
- 抛出:
IOException