- java.lang.Object
-
- org.redkale.net.http.WebSocketReadHandler
-
- 所有已实现的接口:
CompletionHandler<Integer,ByteBuffer>
public class WebSocketReadHandler extends Object implements CompletionHandler<Integer,ByteBuffer>
- 作者:
- zhangjx
-
-
字段概要
字段 修饰符和类型 字段 说明 protected ObjectPool<ByteArray>
byteArrayPool
protected HttpContext
context
protected List<WebSocketPacket>
currPackets
protected ByteArray
currSeriesMergeMessageBytes
protected WebSocketPacket.FrameType
currSeriesMergeMessageType
protected ByteArray
halfFrameBytes
protected byte
halfFrameCrcode
protected int
halfFrameLength
protected byte[]
halfFrameMasks
protected byte
halfFrameOpcode
protected int
halfFrameStart
protected AsyncIOThread
ioReadThread
protected Logger
logger
protected BiConsumer<WebSocket,Object>
restMessageConsumer
protected WebSocket
webSocket
-
构造器概要
构造器 构造器 说明 WebSocketReadHandler(HttpContext context, WebSocket webSocket, ObjectPool<ByteArray> byteArrayPool, BiConsumer<WebSocket,Object> messageConsumer)
-
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 void
completed(Integer count, ByteBuffer readBuffer)
void
failed(Throwable exc, ByteBuffer attachment2)
protected void
readDecode(ByteBuffer realbuf)
消息解码
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-------+-+-------------+-------------------------------+ |F|R|R|R| opcode|M| Payload len | Extended payload length | |I|S|S|S| (4) |A| (7) | (16/64) | |N|V|V|V| |S| | (if payload len==126/127) | | |1|2|3| |K| | | +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - + | Extended payload length continued, if payload len == 127 | + - - - - - - - - - - - - - - - +-------------------------------+ | |Masking-key, if MASK set to 1 | +-------------------------------+-------------------------------+ | Masking-key (continued) | Payload Data | +-------------------------------- - - - - - - - - - - - - - - - + : Payload Data continued : + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + | Payload Data continued | +-----------------------------------------------------------------------+void
startRead()
-
-
-
字段详细资料
-
context
protected final HttpContext context
-
webSocket
protected final WebSocket webSocket
-
restMessageConsumer
protected final BiConsumer<WebSocket,Object> restMessageConsumer
-
logger
protected final Logger logger
-
currPackets
protected final List<WebSocketPacket> currPackets
-
currSeriesMergeMessageBytes
protected ByteArray currSeriesMergeMessageBytes
-
currSeriesMergeMessageType
protected WebSocketPacket.FrameType currSeriesMergeMessageType
-
byteArrayPool
protected final ObjectPool<ByteArray> byteArrayPool
-
halfFrameBytes
protected final ByteArray halfFrameBytes
-
halfFrameOpcode
protected byte halfFrameOpcode
-
halfFrameCrcode
protected byte halfFrameCrcode
-
halfFrameMasks
protected byte[] halfFrameMasks
-
halfFrameStart
protected int halfFrameStart
-
halfFrameLength
protected int halfFrameLength
-
ioReadThread
protected AsyncIOThread ioReadThread
-
-
构造器详细资料
-
WebSocketReadHandler
public WebSocketReadHandler(HttpContext context, WebSocket webSocket, ObjectPool<ByteArray> byteArrayPool, BiConsumer<WebSocket,Object> messageConsumer)
-
-
方法详细资料
-
startRead
public void startRead()
-
readDecode
protected void readDecode(ByteBuffer realbuf)
消息解码
0 1 2 3 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 +-+-+-+-+-------+-+-------------+-------------------------------+ |F|R|R|R| opcode|M| Payload len | Extended payload length | |I|S|S|S| (4) |A| (7) | (16/64) | |N|V|V|V| |S| | (if payload len==126/127) | | |1|2|3| |K| | | +-+-+-+-+-------+-+-------------+ - - - - - - - - - - - - - - - + | Extended payload length continued, if payload len == 127 | + - - - - - - - - - - - - - - - +-------------------------------+ | |Masking-key, if MASK set to 1 | +-------------------------------+-------------------------------+ | Masking-key (continued) | Payload Data | +-------------------------------- - - - - - - - - - - - - - - - + : Payload Data continued : + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + | Payload Data continued | +-----------------------------------------------------------------------+- 参数:
realbuf
- ByteBuffer
-
completed
public void completed(Integer count, ByteBuffer readBuffer)
- 指定者:
completed
在接口中CompletionHandler<Integer,ByteBuffer>
-
failed
public void failed(Throwable exc, ByteBuffer attachment2)
- 指定者:
failed
在接口中CompletionHandler<Integer,ByteBuffer>
-
-