# cell-netty **Repository Path**: lrcchuan2015/cell-netty ## Basic Information - **Project Name**: cell-netty - **Description**: springboot集成netty做物联网,场景:有dtu集中器(电表、水表) - **Primary Language**: Java - **License**: Not specified - **Default Branch**: master - **Homepage**: https://gitee.com/zh-dayong/cell-netty - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 2 - **Created**: 2021-11-14 - **Last Updated**: 2022-12-08 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ##架构分层说明(netty、springboot) 1. cell-api-application 是只有的netty服务与客户端代码实现 2. cell-api-core 是只有做springboot对数据库dao与实体entity 3. cell-api-web 是springboot与netty启动类初始化CellApiWebApplication ##具体类说明 1. cell-api-web 模块的CellApiWebApplication 启动类(也启动netty服务) 2. cell-api-application模块com.cell.api.application.netty.server包下面NettyServer服务端代码 3. 该类初始化默认handler,ServerChannelInitializer该handler初始化加载解码器和编码器,还有心跳设置等等! 4. 连接后,接着会客户端发送消息到服务端,这时候看com.cell.api.application.netty.server包下面NettyServerHandler类的channelRead()方法就好, 里面根据不同的Command功能码,跳转不同的handler,可以用策略模式,目前用工厂模式实现! 5. cell-api-application模块com.cell.api.application.netty.client包下面NettyClient客户端代码,(如果自己启动测试,可以看看,只需要了解就好) ##具截图说明 1. 用socketTool工具调试,模拟客户端发送消息如图: 2. 模拟发送消息:aabb030c000600ffff190002fe01000000 ![img.png](img.png) 4. 服务端接收到消息如图: ![img_1.png](img_1.png) 5. 集中器文档: ![img_2.png](img_2.png)