Skip to content

Commit

Permalink
chore: onRequest和onNotification的应拦截发生在注册的handler中
Browse files Browse the repository at this point in the history
不能像sendRequest和sendNotification这么来
  • Loading branch information
tyn1998 committed Jul 5, 2022
1 parent ba6aa1a commit f3662ad
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
16 changes: 8 additions & 8 deletions packages/connection/src/common/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,14 @@ export function createWebSocketConnection(socket: any) {
}

// onNotification很多的,onRequest我都试不出来
if (prop === 'onRequest' || prop === 'onNotification') {
return function (...args: any) {
if (typeof window !== 'undefined' && window.__OPENSUMI_DEVTOOL_EVENT_SOURCE_TOKEN__) {
window.__OPENSUMI_DEVTOOL_EVENT_SOURCE_TOKEN__.traffic.receive([prop, ...args]);
}
return target[prop].apply(target, [...args]);
};
}
// if (prop === 'onRequest' || prop === 'onNotification') {
// return function (...args: any) {
// if (typeof window !== 'undefined' && window.__OPENSUMI_DEVTOOL_EVENT_SOURCE_TOKEN__) {
// window.__OPENSUMI_DEVTOOL_EVENT_SOURCE_TOKEN__.traffic.receive([prop, ...args]);
// }
// return target[prop].apply(target, [...args]);
// };
// }
return target[prop];
},
});
Expand Down
16 changes: 8 additions & 8 deletions packages/connection/src/node/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@ export function createSocketConnection(socket: net.Socket) {
};
}

if (prop === 'onRequest' || prop === 'onNotification') {
return function (...args: any) {
if (typeof window !== 'undefined' && window.__OPENSUMI_DEVTOOL_EVENT_SOURCE_TOKEN__) {
window.__OPENSUMI_DEVTOOL_EVENT_SOURCE_TOKEN__.traffic.receive([prop, ...args]);
}
return target[prop].apply(target, [...args]);
};
}
// if (prop === 'onRequest' || prop === 'onNotification') {
// return function (...args: any) {
// if (typeof window !== 'undefined' && window.__OPENSUMI_DEVTOOL_EVENT_SOURCE_TOKEN__) {
// window.__OPENSUMI_DEVTOOL_EVENT_SOURCE_TOKEN__.traffic.receive([prop, ...args]);
// }
// return target[prop].apply(target, [...args]);
// };
// }
return target[prop];
},
});
Expand Down

0 comments on commit f3662ad

Please sign in to comment.