public interface IWsMsgHandler
Modifier and Type | Method and Description |
---|---|
HttpResponse |
handshake(HttpRequest httpRequest,
HttpResponse httpResponse,
ChannelContext channelContext)
对httpResponse参数进行补充并返回,如果返回null表示不想和对方建立连接,框架会断开连接,如果返回非null,框架会把这个对象发送给对方
注:请不要在这个方法中向对方发送任何消息,因为这个时候握手还没完成,发消息会导致协议交互失败。
对于大部分业务,该方法只需要一行代码:return httpResponse;
|
void |
onAfterHandshaked(HttpRequest httpRequest,
HttpResponse httpResponse,
ChannelContext channelContext)
握手成功后触发该方法
|
Object |
onBytes(WsRequest wsRequest,
byte[] bytes,
ChannelContext channelContext)
当收到Opcode.BINARY消息时,执行该方法。也就是说如何你的ws是基于BINARY传输的,就会走到这个方法
|
Object |
onClose(WsRequest wsRequest,
byte[] bytes,
ChannelContext channelContext)
当收到Opcode.CLOSE时,执行该方法,业务层在该方法中一般不需要写什么逻辑,空着就好
|
Object |
onText(WsRequest wsRequest,
String text,
ChannelContext channelContext)
当收到Opcode.TEXT消息时,执行该方法。也就是说如何你的ws是基于TEXT传输的,就会走到这个方法
|
HttpResponse handshake(HttpRequest httpRequest, HttpResponse httpResponse, ChannelContext channelContext) throws Exception
httpRequest
- httpResponse
- channelContext
- Exception
void onAfterHandshaked(HttpRequest httpRequest, HttpResponse httpResponse, ChannelContext channelContext) throws Exception
httpRequest
- httpResponse
- channelContext
- Exception
Object onBytes(WsRequest wsRequest, byte[] bytes, ChannelContext channelContext) throws Exception
wsRequest
- bytes
- channelContext
- Exception
Object onClose(WsRequest wsRequest, byte[] bytes, ChannelContext channelContext) throws Exception
wsRequest
- bytes
- channelContext
- Exception
Object onText(WsRequest wsRequest, String text, ChannelContext channelContext) throws Exception
wsRequest
- text
- channelContext
- Exception
Copyright © 2021. All rights reserved.