类 AbstractClientSockJsSession
- java.lang.Object
- org.springframework.web.socket.sockjs.client.AbstractClientSockJsSession
- 所有已实现的接口:
Closeable
,AutoCloseable
,WebSocketSession
public abstract class AbstractClientSockJsSession extends Object implements WebSocketSession
Base class for SockJS client implementations ofWebSocketSession
. Provides processing of incoming SockJS message frames and delegates lifecycle events and messages to the (application)WebSocketHandler
. Sub-classes implement actual send as well as disconnect logic.- 从以下版本开始:
- 4.1
- 作者:
- Rossen Stoyanchev, Juergen Hoeller
构造器概要
构造器 限定符 构造器 说明 protected
AbstractClientSockJsSession(TransportRequest request, WebSocketHandler handler, SettableListenableFuture<WebSocketSession> connectFuture)
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 void
afterTransportClosed(CloseStatus closeStatus)
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.protected void
closeInternal(CloseStatus status)
protected abstract void
disconnect(CloseStatus status)
Map<String,Object>
getAttributes()
Return the map with attributes associated with the WebSocket session.HttpHeaders
getHandshakeHeaders()
Return the headers used in the handshake request (nevernull
).String
getId()
Return a unique session identifier.SockJsMessageCodec
getMessageCodec()
Principal
getPrincipal()
Return aPrincipal
instance containing the name of the authenticated user.URI
getUri()
Return the URI used to open the WebSocket connection.WebSocketHandler
getWebSocketHandler()
void
handleFrame(String payload)
void
handleTransportError(Throwable error)
boolean
isDisconnected()
boolean
isOpen()
Return whether the connection is still open.protected abstract void
sendInternal(TextMessage textMessage)
void
sendMessage(WebSocketMessage<?> message)
Send a WebSocket message: eitherTextMessage
orBinaryMessage
.String
toString()
从类继承的方法 java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
从接口继承的方法 org.springframework.web.socket.WebSocketSession
getAcceptedProtocol, getBinaryMessageSizeLimit, getExtensions, getLocalAddress, getRemoteAddress, getTextMessageSizeLimit, setBinaryMessageSizeLimit, setTextMessageSizeLimit
构造器详细资料
AbstractClientSockJsSession
protected AbstractClientSockJsSession(TransportRequest request, WebSocketHandler handler, SettableListenableFuture<WebSocketSession> connectFuture)
方法详细资料
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
getMessageCodec
public SockJsMessageCodec getMessageCodec()
getWebSocketHandler
public WebSocketHandler getWebSocketHandler()
isOpen
public boolean isOpen()
从接口复制的说明:WebSocketSession
Return whether the connection is still open.- 指定者:
isOpen
在接口中WebSocketSession
isDisconnected
public boolean isDisconnected()
sendMessage
public final 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
.
sendInternal
protected abstract void sendInternal(TextMessage textMessage) throws IOException
- 抛出:
IOException
close
public final 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 final void close(CloseStatus status) throws IOException
从接口复制的说明:WebSocketSession
Close the WebSocket connection with the given close status.- 指定者:
close
在接口中WebSocketSession
- 抛出:
IOException
closeInternal
protected void closeInternal(CloseStatus status) throws IOException
- 抛出:
IOException
disconnect
protected abstract void disconnect(CloseStatus status) throws IOException
- 抛出:
IOException
handleFrame
public void handleFrame(String payload)
handleTransportError
public void handleTransportError(Throwable error)
afterTransportClosed
public void afterTransportClosed(CloseStatus closeStatus)