spring boot集成websocket实现聊天功能和监控功能

本文参考了这位兄台的文章: https://blog.csdn.net/ffj0721/article/details/82630134
项目源码url: https://github.com/zhzhair/websocket-spring-boot.git


项目介绍: InitController类的两个方法分别返回websocket.html和system.html两个页面。类MyWebSocket和SystemWebSocket分别对应聊天功能和监控功能。WebSocketConfig注册websocket服务:
  启动启动类,访问聊天页面: http://localhost:8080/websocket, 打开多个页面模拟多个客户端,输入内容点击Send就可以聊天了,访问url: http://localhost:8080/

sendToAll实现群发消息, 如图所示:


  

  访问http://localhost:8080/system,可以看到如下的监控信息:  

 

posted @ 2019-04-11 21:22  zhzhair-codestyle  阅读(978)  评论(0编辑  收藏  举报