一.练习Netty(心跳,粘包,protobuf)

       配置protobuf,用客户端发送至服务端,服务端解析并设置心跳,服务端回应bytebuf,客户端解析并粘包拆包处理

1.配置protobuf

Netty练习(心跳,粘包,protobuf)Netty练习(心跳,粘包,protobuf)

2.在工程里创建lib,和proto文件夹,netty  jar和 protobuf  jar  导入到 lib文件夹,配置好的player.proto文件放入proto文件夹。

   之后打开工程路径,把配置好的build.bat文件和proto.exe,放入。运行proto.exe,回到工程中刷新,产生PlayerModule类既可。

Netty练习(心跳,粘包,protobuf)


3.终于不用墨迹了,^__^

Client客户端

Netty练习(心跳,粘包,protobuf)Netty练习(心跳,粘包,protobuf)


ClientHandler 核心处理类

Netty练习(心跳,粘包,protobuf)


Server服务端

Netty练习(心跳,粘包,protobuf)Netty练习(心跳,粘包,protobuf)


ServerHandler  核心处理类

Netty练习(心跳,粘包,protobuf)


运行结果:

Netty练习(心跳,粘包,protobuf)


^__^       简单的实现,多有不足~

相关文章:

  • 2021-12-28
  • 2021-09-20
  • 2022-01-22
  • 2021-05-26
  • 2021-08-06
  • 2021-11-20
  • 2021-07-23
  • 2021-07-08
猜你喜欢
  • 2023-02-10
  • 2021-11-22
  • 2021-11-04
  • 2021-05-28
  • 2022-12-23
  • 2021-08-13
  • 2021-10-19
相关资源
相似解决方案