mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 21:00:57 +00:00
Improve duplicate module filtering. Update SocketIO catch-all API. (#3523)
- [x] Base your pull requests against the `develop` branch. - [x] Include these infos in the description: > - Does the pull request solve a **related** issue? Yes - solves #3521 > - If so, can you reference the issue like this `Fixes #<issue_number>`? Fixes #3521 (also mentioned in commit message) > - What does the pull request accomplish? Use a list if needed. > > - Updates duplicate module filter method (upstream vs downstream - see #3502) > > - Updates socket io catchall functionality to new API [[docs](https://socket.io/docs/v4/listening-to-events/)]. - [x] Please run `npm run lint:prettier` before submitting - [x] Don't forget to add an entry about your changes to the CHANGELOG.md file.
This commit is contained in:
@@ -86,20 +86,9 @@ const NodeHelper = Class.extend({
|
||||
Log.log(`Connecting socket for: ${this.name}`);
|
||||
|
||||
io.of(this.name).on("connection", (socket) => {
|
||||
// add a catch all event.
|
||||
const onevent = socket.onevent;
|
||||
socket.onevent = function (packet) {
|
||||
const args = packet.data || [];
|
||||
onevent.call(this, packet); // original call
|
||||
packet.data = ["*"].concat(args);
|
||||
onevent.call(this, packet); // additional call to catch-all
|
||||
};
|
||||
|
||||
// register catch all.
|
||||
socket.on("*", (notification, payload) => {
|
||||
if (notification !== "*") {
|
||||
this.socketNotificationReceived(notification, payload);
|
||||
}
|
||||
socket.onAny((notification, payload) => {
|
||||
this.socketNotificationReceived(notification, payload);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user