websocket消息订阅

import SockJS from  ‘sockjs-client‘;
import Stomp from ‘stompjs‘;

ws(url, subUrl) {
        return new Promise((resolve, reject) => {
            let socket = new SockJS(url)
            let stompClient = Stomp.over(socket)
            stompClient.connect({}, () => {
                stompClient.subscribe(subUrl, function (message) {
                    try {
                        resolve(message.body)
                    } catch (err) {
                        reject(err)
                    }
                })
            })
        })
    }

 

websocket消息订阅

上一篇:Django URL路由


下一篇:sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class异常解决方法