Skip to content

Commit 16544d6

Browse files
committed
Netty-Websocket : 消息处理
1 parent d675d02 commit 16544d6

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

netty/netty-websocket/src/main/java/org/ylc/note/netty/websocket/handler/SocketMessageHandler.java

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,46 @@
1414
* @date 2021/1/11
1515
*/
1616
public class SocketMessageHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {
17+
18+
19+
/**
20+
* 建立连接是触发
21+
*
22+
* @param ctx
23+
* @throws Exception
24+
*/
25+
@Override
26+
public void channelActive(ChannelHandlerContext ctx) throws Exception {
27+
super.channelActive(ctx);
28+
}
29+
30+
/**
31+
* 断开连接是触发
32+
*
33+
* @param ctx
34+
* @throws Exception
35+
*/
36+
@Override
37+
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
38+
super.channelInactive(ctx);
39+
}
40+
41+
/**
42+
* 服务端接受客户端消息
43+
*
44+
* @param channelHandlerContext
45+
* @param textWebSocketFrame
46+
* @throws Exception
47+
*/
1748
@Override
1849
protected void channelRead0(ChannelHandlerContext channelHandlerContext, TextWebSocketFrame textWebSocketFrame) throws Exception {
1950

2051
}
52+
53+
/**
54+
* 给客户端发送消息
55+
*/
56+
private void sendMessage() {
57+
58+
}
2159
}

0 commit comments

Comments
 (0)