订阅处理

This commit is contained in:
joylink_fanyuhong 2024-11-12 09:17:32 +08:00
parent cdcad825f7
commit 33292ca9b8
2 changed files with 9 additions and 6 deletions

View File

@ -267,12 +267,12 @@ export function cancelSubscribe(lineApp: IGraphicApp) {
if (lineId) { if (lineId) {
lineApp.unsubscribe(`/queue/line/${lineId}/device`); lineApp.unsubscribe(`/queue/line/${lineId}/device`);
lineApp.unsubscribe(`/queue/line/${lineId}/train`); lineApp.unsubscribe(`/queue/line/${lineId}/train`);
const userStore = useUserStore(); monitorDestinations.forEach((destination) => {
getMonitorPath(userStore.roles).destinations.forEach((destination) => {
lineApp.unsubscribe(destination); lineApp.unsubscribe(destination);
}); });
} }
} }
let monitorDestinations: string[] = [];
function handleSubscribe(lineApp: IGraphicApp) { function handleSubscribe(lineApp: IGraphicApp) {
const lineStore = useLineStore(); const lineStore = useLineStore();
const lineId = lineStore.lineId; const lineId = lineStore.lineId;
@ -327,7 +327,8 @@ function handleSubscribe(lineApp: IGraphicApp) {
}); });
const lineNetStore = useLineNetStore(); const lineNetStore = useLineNetStore();
const userStore = useUserStore(); const userStore = useUserStore();
getMonitorPath(userStore.roles).destinations.forEach((destination) => { monitorDestinations = getMonitorPath(userStore.roles).destinations;
monitorDestinations.forEach((destination) => {
lineApp.subscribe({ lineApp.subscribe({
destination, destination,
messageHandle: (message: Uint8Array) => { messageHandle: (message: Uint8Array) => {

View File

@ -151,11 +151,12 @@ export async function loadLineNetDatas(): Promise<IGraphicStorage> {
export function cancelSubscribe(lineNetApp: IGraphicApp) { export function cancelSubscribe(lineNetApp: IGraphicApp) {
lineNetApp.unsubscribe('/queue/lineNet'); lineNetApp.unsubscribe('/queue/lineNet');
const userStore = useUserStore(); monitorDestinations.forEach((destination) => {
getMonitorPath(userStore.roles).destinations.forEach((destination) => {
lineNetApp.unsubscribe(destination); lineNetApp.unsubscribe(destination);
}); });
} }
let monitorDestinations: string[] = [];
export function handleSubscribe(lineNetApp: IGraphicApp) { export function handleSubscribe(lineNetApp: IGraphicApp) {
const lineNetStore = useLineNetStore(); const lineNetStore = useLineNetStore();
lineNetApp.enableWsMassaging({ lineNetApp.enableWsMassaging({
@ -175,7 +176,8 @@ export function handleSubscribe(lineNetApp: IGraphicApp) {
}, },
}); });
const userStore = useUserStore(); const userStore = useUserStore();
getMonitorPath(userStore.roles).destinations.forEach((destination) => { monitorDestinations = getMonitorPath(userStore.roles).destinations;
monitorDestinations.forEach((destination) => {
lineNetApp.subscribe({ lineNetApp.subscribe({
destination, destination,
messageHandle: (message: Uint8Array) => { messageHandle: (message: Uint8Array) => {