• vue中 搭配 springboot整合websocket实现一对一消息推送和广播消息推送


    https://www.cnblogs.com/javafirst0/p/11208563.html

    https://www.cnblogs.com/luoxuemei/p/10115679.html

    https://www.cnblogs.com/luoxuemei/p/10115679.html

    mounted(){
        this.connect(this);
      },
    
    methods: {
    connect(_this) {
          var socket = new SockJS(window.g_api.BASE_API+'/readerSocket'); //1连接SockJS的endpoint是“endpointWisely”,与后台代码中注册的endpoint要一样。
          let stompClient = Stomp.over(socket);//2创建STOMP协议的webSocket客户端。
          stompClient.connect({}, function(frame) {//3连接webSocket的服务端。
              // setConnected(true);
              console.log('开始进行连接Connected: ' + frame);
              //4通过stompClient.subscribe()订阅服务器的目标是'/topic/getResponse'发送过来的地址,与@SendTo中的地址对应。
              stompClient.subscribe('/topic/getNotics', function(respnose){
                console.log(respnose)
                console.log(respnose.body)
                console.log(_this)
                if(respnose.body=='密码重置'){
                  _this.resetPassStatus = true;
                  _this.$store.commit("FORGET_PASS_STATUS",true);
                }
                  // showResponse(JSON.parse(respnose.body).responseMessage);
              });
          });
         
        },
    }
  • 相关阅读:
    jQuery tablesort插件推荐
    更改firefox默认搜索引擎
    Chrome Firefox 自定义背景色
    python 基础之列表切片内置方法
    python 基础之while无限循环
    python 基础之for循环有限循环
    python 基础之格式化输出
    nginx之HTTP模块配置
    Kubernetes之pod的属性
    nginx的工作流程
  • 原文地址:https://www.cnblogs.com/web-aqin/p/15061286.html
Copyright © 2020-2023  润新知