2021-03-02-星期二-工作总结

工作:

1、今天早上思考出了如何合并时间段的算法。

用两个循环,一个循环负责将一个时间段合并进入最终时间段集合中,另一个循环负责对最终时间段集合进行重新规整。

2、调研websocket。

java做websocket服务端目前三种方法。

(1)javaee中自带的websocket服务端方案,使用注解@ServerEndpoint

<dependency>
   <groupId>javax.websocket</groupId>
   <artifactId>javax.websocket-api</artifactId>
   <version>1.1</version>
   <scope>provided</scope>
</dependency>

(2)Springboot整合的websocket方案。springboot对websocket支持很友好,只需要继承SpringWebSocketHandler 类,重写几个方法就可以了

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-websocket</artifactId>

    <version>2.0.4.RELEASE</version>

</dependency>

 

(3)netty-websocket

<dependency>

<groupId>com.corundumstudio.socketio</groupId>

<artifactId>netty-socketio</artifactId>

<version>1.7.7</version>

</dependency>

com.corundumstudio.socketio.SocketConfig

com.corundumstudio.socketio.SocketIOServer

 

下面三篇文章对理解netty-websocket非常有益处:

1、https://www.cnblogs.com/luxiaoxun/p/4279997.html  基于netty-socketio的web推送服务

2、https://blog.csdn.net/zk1z23456789/article/details/90612164 基于netty实现websocket高并发服务

3、https://www.cnblogs.com/zyulike/p/10775358.html SpringBoot项目集成socketIo实现实时推送

 

目前项目中是netty-websocket方式。

 

3、搞清楚了socketio。

服务端用netty-socketio来做,客户端用socket.io.js来做。

socketio和websocket的关系搞清楚了,socketio对websocket做了一层封装,具有更好的兼容性和易用性。

 

posted @ 2021-03-02 09:53  zhangzl419  阅读(72)  评论(0)    收藏  举报