public class WsServerAioHandler extends Object implements ServerAioHandler
Constructor and Description |
---|
WsServerAioHandler(WsServerConfig wsServerConfig,
IWsMsgHandler wsMsgHandler) |
Modifier and Type | Method and Description |
---|---|
WsRequest |
decode(ByteBuffer buffer,
int limit,
int position,
int readableLength,
ChannelContext channelContext)
根据ByteBuffer解码成业务需要的Packet对象.
|
ByteBuffer |
encode(Packet packet,
TioConfig tioConfig,
ChannelContext channelContext)
编码
|
WsServerConfig |
getHttpConfig() |
void |
handler(Packet packet,
ChannelContext channelContext)
处理消息包
|
void |
setHttpConfig(WsServerConfig httpConfig) |
static HttpResponse |
updateWebSocketProtocol(HttpRequest request,
ChannelContext channelContext)
本方法改编自baseio: https://gitee.com/generallycloud/baseio
感谢开源作者的付出 |
public WsServerAioHandler(WsServerConfig wsServerConfig, IWsMsgHandler wsMsgHandler)
wsServerConfig
- wsMsgHandler
- public WsRequest decode(ByteBuffer buffer, int limit, int position, int readableLength, ChannelContext channelContext) throws TioDecodeException
AioHandler
decode
in interface AioHandler
buffer
- 参与本次希望解码的ByteBufferlimit
- ByteBuffer的limitposition
- ByteBuffer的position,不一定是0哦readableLength
- ByteBuffer参与本次解码的有效数据(= limit - position)AioDecodeException
TioDecodeException
public ByteBuffer encode(Packet packet, TioConfig tioConfig, ChannelContext channelContext)
AioHandler
encode
in interface AioHandler
public WsServerConfig getHttpConfig()
public void handler(Packet packet, ChannelContext channelContext) throws Exception
AioHandler
handler
in interface AioHandler
Exception
public void setHttpConfig(WsServerConfig httpConfig)
httpConfig
- the httpConfig to setpublic static HttpResponse updateWebSocketProtocol(HttpRequest request, ChannelContext channelContext)
request
- channelContext
- Copyright © 2021. All rights reserved.