Skip to content

Commit 2856747

Browse files
authored
Merge pull request #98 from sdetweil/multiinstance
change to support multiple instances even with same url
2 parents 4133626 + e2af0d3 commit 2856747

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

MMM-JsonTable.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,14 +31,14 @@ Module.register("MMM-JsonTable", {
3131

3232
// Request node_helper to get json from url
3333
getJson () {
34-
this.sendSocketNotification("MMM-JsonTable_GET_JSON", this.config.url);
34+
this.sendSocketNotification("MMM-JsonTable_GET_JSON", {url:this.config.url,id:this.identifier});
3535
},
3636

3737
socketNotificationReceived (notification, payload) {
3838
if (notification === "MMM-JsonTable_JSON_RESULT") {
3939
// Only continue if the notification came from the request we made
4040
// This way we can load the module more than once
41-
if (payload.url === this.config.url) {
41+
if (payload.id === this.identifier) {
4242
this.jsonData = payload.data;
4343
this.updateDom(this.config.animationSpeed);
4444
}

node_helper.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,24 @@ module.exports = NodeHelper.create({
66
Log.log("MMM-JsonTable helper started...");
77
},
88

9-
getJson (url) {
9+
getJson (payload) {
1010
const self = this;
1111

12-
fetch(url)
12+
fetch(payload.url)
1313
.then((response) => response.json())
1414
.then((json) => {
1515
// Send the json data back with the url to distinguish it on the receiving part
1616
self.sendSocketNotification("MMM-JsonTable_JSON_RESULT", {
17-
url,
17+
id:payload.id,
1818
data: json
1919
});
2020
});
2121
},
2222

2323
// Subclass socketNotificationReceived received.
24-
socketNotificationReceived (notification, url) {
24+
socketNotificationReceived (notification, payload ) {
2525
if (notification === "MMM-JsonTable_GET_JSON") {
26-
this.getJson(url);
26+
this.getJson(payload);
2727
}
2828
}
2929
});

0 commit comments

Comments
 (0)