public class WebSocketDispatcher extends Object
Modifier and Type | Class and Description |
---|---|
static class |
WebSocketDispatcher.WebSocketEvent |
Modifier and Type | Field and Description |
---|---|
static HashWheelTimer |
HEARTBEAT_WHEEL_TIMER |
Constructor and Description |
---|
WebSocketDispatcher(WebServerConfig webConfig,
SessionManager sessionManager)
构造函数
|
Modifier and Type | Method and Description |
---|---|
void |
addRouteHandler(String routePath,
WebSocketRouter handler)
增加一个路由规则
|
WebSocketSession |
disposeSession(HttpRequest request,
WebSocketRouter webSocketRouter)
处理 WebSocketSession
|
static Object |
filterDecoder(WebSocketSession session,
Chain<WebSocketFilter> wsFilterChain,
Object result)
过滤器解密函数,接收事件(onRecive)前调用
onRecive事件前调用
|
static Object |
filterDecoder(WebSocketSession session,
Object result)
过滤器解密函数,接收事件(onRecive)前调用
onRecive事件前调用
|
static Object |
filterEncoder(WebSocketSession session,
Chain<WebSocketFilter> wsFilterChain,
Object result)
使用过滤器编码结果
|
static Object |
filterEncoder(WebSocketSession session,
Object result)
过滤器解密函数,接收事件(onRecive)前调用
onRecive事件前调用
|
org.voovan.http.server.RouterWrap<WebSocketRouter> |
findRouter(HttpRequest request)
获取路由处理对象和注册路由
|
void |
fireCloseEvent(IoSession session)
出发 Close 事件
|
WebSocketFrame |
fireOpenEvent(IoSession session,
HttpRequest request)
触发 WebSocket Open 事件
|
WebSocketFrame |
firePingEvent(IoSession session,
HttpRequest request,
ByteBuffer byteBuffer)
触发 WebSocket Ping 事件
|
void |
firePoneEvent(IoSession session,
HttpRequest request,
ByteBuffer byteBuffer)
触发 WebSocket Pone 事件
|
WebSocketFrame |
fireReceivedEvent(IoSession session,
HttpRequest request,
ByteBuffer byteBuffer)
触发 WebSocket Received 事件
|
void |
fireSentEvent(IoSession session,
HttpRequest request,
ByteBuffer byteBuffer)
触发 WebSocket Sent 事件
|
static HashWheelTimer |
getHeartBeatWheelTimer() |
Map<String,org.voovan.http.server.RouterWrap<WebSocketRouter>> |
getRouters()
获取 WebSocket 的路由配置
|
WebSocketFrame |
process(WebSocketDispatcher.WebSocketEvent event,
IoSession session,
HttpRequest request,
ByteBuffer byteBuffer)
路由处理函数
|
public static HashWheelTimer HEARTBEAT_WHEEL_TIMER
public WebSocketDispatcher(WebServerConfig webConfig, SessionManager sessionManager)
webConfig
- WEB 配置对象sessionManager
- session 管理器public static HashWheelTimer getHeartBeatWheelTimer()
public Map<String,org.voovan.http.server.RouterWrap<WebSocketRouter>> getRouters()
public void addRouteHandler(String routePath, WebSocketRouter handler)
routePath
- 匹配路径handler
- WebSocketRouter 对象public org.voovan.http.server.RouterWrap<WebSocketRouter> findRouter(HttpRequest request)
request
- 请求对象public static Object filterDecoder(WebSocketSession session, Chain<WebSocketFilter> wsFilterChain, Object result) throws WebSocketFilterException
session
- session 对象wsFilterChain
- 过滤器链result
- 解码对象,上一个过滤器的返回值WebSocketFilterException
- WebSocket过滤器异常public static Object filterDecoder(WebSocketSession session, Object result) throws WebSocketFilterException
session
- session 对象result
- 解码对象,上一个过滤器的返回值WebSocketFilterException
- WebSocket过滤器异常public static Object filterEncoder(WebSocketSession session, Chain<WebSocketFilter> wsFilterChain, Object result) throws WebSocketFilterException
session
- Session 对象wsFilterChain
- 过滤器链result
- 需编码的对象WebSocketFilterException
- WebSocket过滤器异常public static Object filterEncoder(WebSocketSession session, Object result) throws WebSocketFilterException
session
- session 对象result
- 解码对象,上一个过滤器的返回值WebSocketFilterException
- WebSocket过滤器异常public WebSocketFrame process(WebSocketDispatcher.WebSocketEvent event, IoSession session, HttpRequest request, ByteBuffer byteBuffer)
event
- WebSocket 事件session
- socket连接会话request
- HTTP 请求对象byteBuffer
- 对象, 保存 WebSocket 数据public WebSocketSession disposeSession(HttpRequest request, WebSocketRouter webSocketRouter)
request
- Http 请求对象webSocketRouter
- websocket 路由处理public WebSocketFrame fireOpenEvent(IoSession session, HttpRequest request)
session
- socket 会话对象request
- http 请求对象public WebSocketFrame fireReceivedEvent(IoSession session, HttpRequest request, ByteBuffer byteBuffer)
session
- socket 会话对象request
- http 请求对象byteBuffer
- ping的报文数据public void fireSentEvent(IoSession session, HttpRequest request, ByteBuffer byteBuffer)
session
- socket 会话对象request
- http 请求对象byteBuffer
- ByteBuffer 对象public void fireCloseEvent(IoSession session)
session
- HTTP-Session 对象public WebSocketFrame firePingEvent(IoSession session, HttpRequest request, ByteBuffer byteBuffer)
session
- socket 会话对象request
- http 请求对象byteBuffer
- ping的报文数据public void firePoneEvent(IoSession session, HttpRequest request, ByteBuffer byteBuffer)
session
- socket 会话对象request
- http 请求对象byteBuffer
- ByteBuffer 对象Copyright © 2020 Voovan. All rights reserved.