public class WebSocketSession extends Attributes
Constructor and Description |
---|
WebSocketSession(IoSession socketSession,
WebSocketRouter webSocketRouter,
WebSocketType webSocketType)
构造函数
|
Modifier and Type | Method and Description |
---|---|
void |
close()
关闭 WebSocket
|
HttpSession |
getHttpSession()
获取 Http 的 session
|
String |
getLocation()
获取WebSocket的地址
|
String |
getRemoteAddress()
获取对端连接的 IP
|
int |
getRemotePort()
获取对端连接的端口
|
protected IoSession |
getSocketSession() |
WebSocketRouter |
getWebSocketRouter()
获取 WebSocket 路由处理对象
|
boolean |
isConnected()
判断连接状态
|
void |
send(Object obj)
发送 websocket 消息
|
protected void |
send(WebSocketFrame webSocketFrame)
发送 websocket 帧
|
void |
sendBinary(Object obj)
发送 websocket 消息二进制消息
|
void |
setSocketSession(IoSession socketSession) |
void |
setWebSocketRouter(WebSocketRouter webSocketRouter)
设置获取WebSocket 路由处理对象
|
attributes, clearAttribute, containAttribute, getAttribute, isModifyed, removeAttribute, setAttribute, setModifyed
public WebSocketSession(IoSession socketSession, WebSocketRouter webSocketRouter, WebSocketType webSocketType)
socketSession
- Socket 会话webSocketRouter
- WebSocket 路由处理对象webSocketType
- WebSocket类型public String getLocation()
public HttpSession getHttpSession()
public String getRemoteAddress()
public int getRemotePort()
public WebSocketRouter getWebSocketRouter()
public void setWebSocketRouter(WebSocketRouter webSocketRouter)
webSocketRouter
- WebSocket 路由处理对象public void send(Object obj) throws SendMessageException, WebSocketFilterException
obj
- 消息对象SendMessageException
- 发送异常WebSocketFilterException
- WebSocket过滤器异常public void sendBinary(Object obj) throws SendMessageException, WebSocketFilterException
obj
- 消息对象SendMessageException
- 发送异常WebSocketFilterException
- WebSocket过滤器异常protected void send(WebSocketFrame webSocketFrame) throws SendMessageException
webSocketFrame
- 帧SendMessageException
- 发送异常public boolean isConnected()
public void close()
protected IoSession getSocketSession()
public void setSocketSession(IoSession socketSession)
Copyright © 2020 Voovan. All rights reserved.