Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Commit

Permalink
chromecast: avoid leaking Chromecast implementation in other classes
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentbernat committed Jan 25, 2015
1 parent 3da2f21 commit 87a4f9b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
13 changes: 9 additions & 4 deletions app/scripts/chromecast.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,24 @@
appConfig = new cast.receiver.CastReceiverManager.Config();
appConfig.maxInactivity = inactivity;
appConfig.statusText = 'Waiting for an URL';
this.castReceiverManager = cast.receiver.CastReceiverManager.getInstance();
var castReceiverManager = cast.receiver.CastReceiverManager.getInstance();

// Setup message bus
this.messageBus = this.castReceiverManager
var messageBus = castReceiverManager
.getCastMessageBus(urn);
this.messageBus.onMessage = function(event) {
messageBus.onMessage = function(event) {
var message = JSON.parse(event.data),
url = message.url;
self.load(url);
};

// Setup callback when a URL is loaded
this.onUrlLoad = function(url) {
castReceiverManager.setApplicationState('Receiver: ' + url);
};

// Start
this.castReceiverManager.start(appConfig);
castReceiverManager.start(appConfig);
};

})(window.dkSupervisor, window.cast, window);
4 changes: 3 additions & 1 deletion app/scripts/device-receiver.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
(a.hash || '') +
'#timeout=' + this.timeout;

this.castReceiverManager.setApplicationState('Receiver: ' + this.url);
if (this.onUrlLoad) {
this.onUrlLoad(this.url);
}

var shortened = this.url;
if (shortened.indexOf('#')) {
Expand Down

0 comments on commit 87a4f9b

Please sign in to comment.