基于Netty实现的WebSocket聊天室,实现的功能如下:
The WebSocket chat room based on Netty is implemented as follows:
- 支持昵称登录/Support nickname login;
- 支持多人同时在线/Support multiple people online at the same time;
- 同步显示在线人数/Synchronous display of online number;
- 支持文字和表情的内容/Support words and expressions;
- 浏览器与服务器保持长连接,定时心跳检测/The browser maintains a long connection with the server and detects heartbeat regularly.;
将代码下载下来,导入idea为maven项目,启动HappyChatMain的server端
直接通过浏览器打开docs文件夹下的index.html,随便输入昵称登陆,开启两个浏览器窗口登陆,然后随便发送几条消息
Download the code, import idea into Maven project, and start the server end of HappyChatMain.java.
Open index.html under the docs folder directly through the browser, enter the nickname login, open two browser windows to login, and then send a few messages randomly: