当前位置: 首页 > news >正文

想学做网站学什么教程社区网站建设工作职责

想学做网站学什么教程,社区网站建设工作职责,菏泽网站建设电话,哪个网站做签约设计师比较好系列文章目录 一、SpringBoot连接MySQL数据库实例【tk.mybatis连接mysql数据库】 二、SpringBoot连接Redis与Redisson【代码】 三、SpringBoot整合WebSocket【代码】 四、SpringBoot整合ElasticEearch【代码示例】 文章目录 系列文章目录代码下载地址一、效果演示二、引入依赖…系列文章目录 一、SpringBoot连接MySQL数据库实例【tk.mybatis连接mysql数据库】 二、SpringBoot连接Redis与Redisson【代码】 三、SpringBoot整合WebSocket【代码】 四、SpringBoot整合ElasticEearch【代码示例】 文章目录 系列文章目录代码下载地址一、效果演示二、引入依赖三、WebSocketConfig四、SessionWrap五、WebSocketServer 代码下载地址 SpringBoot整合WebSocket【代码】 一、效果演示 测试链接 二、引入依赖 !-- websocket -- dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-websocket/artifactIdversion2.1.1.RELEASE/version /dependency三、WebSocketConfig Configuration public class WebSocketConfig {Beanpublic ServerEndpointExporter serverEndpointExporter() {return new ServerEndpointExporter();} }四、SessionWrap SessionWrap 可根据具体需求自定义 Data public class SessionWrap {private String from; // 连接Idprivate String type; // 来凝结类型private Session session;private Date lastTime; }五、WebSocketServer Slf4j Component ServerEndpoint(value /api/websocket/{from}/{type}) public class WebSocketServer {Autowiredprivate MessageService messageService;public static WebSocketServer webSocketServer;// 所有的连接会话private static CopyOnWriteArraySetSessionWrap sessionList new CopyOnWriteArraySet();private String from;private String type;PostConstructpublic void init() {webSocketServer this;webSocketServer.messageService this.messageService;}/*** author Lee* date 2023/7/18 13:57* description 创建连接*/OnOpenpublic void onOpen(Session session, PathParam(value from) String from, PathParam(value type) String type) {this.from from;this.type type;try {// 遍历list如果有会话更新如果没有创建一个新的for (SessionWrap item : sessionList) {if (item.getFrom().equals(from) item.getType().equals(type)) {item.setSession(session);item.setLastTime(new Date());log.info(【websocket消息】更新连接总数为: sessionList.size());return;}}SessionWrap sessionWrap new SessionWrap();sessionWrap.setFrom(from);sessionWrap.setType(type);sessionWrap.setSession(session);sessionWrap.setLastTime(new Date());sessionList.add(sessionWrap);log.info(【websocket消息】有新的连接总数为: sessionList.size());} catch (Exception e) {log.info(【websocket消息】连接失败错误信息 e.getMessage());}}/*** author Lee* date 2023/7/18 13:57* description 关闭连接*/OnClosepublic void onClose() {try {sessionList.removeIf(item - item.getFrom().equals(from) item.getType().equals(type));log.info(【websocket消息】连接断开总数为: sessionList.size());} catch (Exception e) {log.info(【websocket消息】连接断开失败错误信息 e.getMessage());}}/*** author Lee* date 2023/7/18 14:04* description 发送消息*/OnMessagepublic void onMessage(String message, Session session) {try {// 对消息进行处理JSONObject r webSocketServer.messageService.insertMessage(message);String userId r.getString(userId);for (SessionWrap item : sessionList) {// 发送消息的判断逻辑可根据需求修改if (item.getFrom().equals(userId) item.getType().equals(test)) {item.getSession().getBasicRemote().sendText(r.toJSONString());log.info(【websocket消息】发送消息成功: r.toJSONString());}}} catch (Exception e) {log.info(【websocket消息】发送消息失败错误信息 e.getMessage());}}OnErrorpublic void onError(Session session, Throwable error) {log.error(用户错误,原因:error.getMessage());error.printStackTrace();}}
http://www.dnsts.com.cn/news/185042.html

相关文章:

  • 如何做慕课网站俄罗斯乌克兰
  • 没有网站如何做cps北京网络公司哪家最好
  • 快速搭建网站后天台网站建设和网络推广外包
  • asp.net网站开发之美做网站需要什么素材
  • 网站五合一建设爱建站大全网
  • 现代示范校建设专题网站机关单位网站建设的重要性
  • 宁波网站建设价格中山企业网站建设公司
  • 比价网站源码做网站怎么移动图片
  • 优惠券网站是怎么做的物流外贸是做什么的
  • 建设网站前期准备工作东源县住房和城乡建设部网站
  • 公司网站设计思路建设信用卡银行积分商城网站
  • 网站建设yingkagou招聘网页怎么制作
  • 龙岗区住房建设局网站手机淘宝官网
  • 什么网站可以做调查恩施建站建设
  • 平台软件怎么制作开发网站优化设计方案怎么做
  • fwa 网站 欣赏html网页设计大赛作品
  • 英文网站案例杭州app定制公司
  • 西安网站制作有限公司建立网站需要多少钱八寇湖南岚鸿团队
  • h5case什么网站做网站咸阳
  • 做的好看的pc端网站网站 前台后台
  • 建立充电站需要多少钱WordPress考试
  • 网站开发使用软件环境什么是优化型网站
  • 重庆市建设执业注册中心网站dedecms物流企业网站模板(适合快递
  • 举报网站建设情况汇报wordlink网站开发
  • 黑色风格网站主页面南京营销
  • 基于php的家具公司网站开发软件定制
  • 展示照片的网站模板wordpress官网插件
  • 怎么查网站备案信息小程序商店图标
  • 电子商务网站建设背景关键字优化技巧
  • 让别人做一个网站需要多少钱做非法网站判什么邢