From 527373b2bd39d996be0a03158d07a60ec79fcf24 Mon Sep 17 00:00:00 2001 From: Christian Sigritz Date: Fri, 6 Jan 2017 13:23:36 +0100 Subject: [PATCH] Added Socket Handler for ZoneMapChanged Event --- api.js | 8 ++++++++ sample.js | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/api.js b/api.js index 19ebcf5..e039e6d 100644 --- a/api.js +++ b/api.js @@ -305,6 +305,10 @@ SoundTouchAPI.prototype.socketUpdate = function(json) { if (this.socket.recentsUpdatedListener != undefined) { this.socket.recentsUpdatedListener(json.recentsUpdated); } + } else if (json.zoneUpdated != undefined) { + if (this.socket.zoneUpdatedListener != undefined) { + this.socket.zoneUpdatedListener(json.zoneUpdated); + } } else { console.log("Other update", json); } @@ -338,6 +342,10 @@ SoundTouchAPI.prototype.setRecentsUpdatedListener = function(handler) { this.socket.recentsUpdatedListener = handler; }; +SoundTouchAPI.prototype.setZoneUpdatedListener = function(handler) { + this.socket.zoneUpdatedListener = handler; +}; + /* ****** UTILITY METHODS *********** */ diff --git a/sample.js b/sample.js index c094478..4e8d8e1 100644 --- a/sample.js +++ b/sample.js @@ -45,5 +45,9 @@ soundTouchDiscovery.search(function(deviceAPI) { console.log("NOW SELECTION UPDATED", json); }); + deviceAPI.setZoneUpdatedListener(function(json) { + console.log("ZONE UPDATED", json); + }); + soundTouchDiscovery.stopSearching(); }); \ No newline at end of file