socket重复订阅问题修复

This commit is contained in:
fan 2023-05-04 17:23:51 +08:00
parent 0395d6d470
commit bbf9e9ba0e

View File

@ -37,7 +37,10 @@ StompClient.prototype = {
heartbeatOutgoing: 30000,
onConnect: () => {
this.subscribeMap.forEach(subscribe => {
this.clientIns.subscribe(subscribe.dest, subscribe.handler, subscribe.headers);
if (!subscribe.sub) {
const sub = this.clientIns.subscribe(subscribe.dest, subscribe.handler, subscribe.headers);
this.subscribeMap.set(subscribe.dest, {dest: subscribe.dest, handler: onmessage, sub: sub, headers: subscribe.headers, count: 1});
}
});
Notification.closeAll();
this.status = true;
@ -93,7 +96,6 @@ StompClient.prototype = {
// 订阅指定的topic
subscribe(topic, onmessage, headers) {
console.log(topic, onmessage, headers);
this.topic = topic;
this.onmessage = onmessage;
this.headers = headers;