代码:
后端:
POM:
<dependency>
<groupId>org.t-io</groupId>
<artifactId>tio-websocket-spring-boot-starter</artifactId>
<version>3.3.2.v20190601-RELEASE</version>
</dependency>
配置类:
public class MyWebSocketMsgHandler implements IWsMsgHandler {
@Override
public HttpResponse handshake(HttpRequest httpRequest, HttpResponse httpResponse, ChannelContext channelContext) throws Exception {
return httpResponse;
}
@Override
public void onAfterHandshaked(HttpRequest httpRequest, HttpResponse httpResponse, ChannelContext channelContext) throws Exception {
System.out.println("握手成功");
}
@Override
public Object onBytes(WsRequest wsRequest, byte[] bytes, ChannelContext channelContext) throws Exception {
System.out.println("接收到bytes消息");

最低0.47元/天 解锁文章
&spm=1001.2101.3001.5002&articleId=114931678&d=1&t=3&u=badab35b3d554c90afa848760bf3b286)
20万+

被折叠的 条评论
为什么被折叠?



