-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChromecast.Receiver.js
More file actions
20 lines (18 loc) · 908 Bytes
/
Chromecast.Receiver.js
File metadata and controls
20 lines (18 loc) · 908 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
var Chromecast = Chromecast || {};
Chromecast.Receiver = function (debugString, messageCommands) {
this.messageCommands = messageCommands;
this.receiver = new cast.receiver.Receiver(Chromecast.Settings.appId, [Chromecast.Settings.namespace], '', 5);
this.mChannelHandler = new cast.receiver.ChannelHandler(debugString);
this.mChannelHandler.addEventListener(cast.receiver.Channel.EventType.MESSAGE, this.onMessage.bind(this));
this.mChannelHandler.addChannelFactory(this.receiver.createChannelFactory(Chromecast.Settings.namespace));
this.receiver.start();
};
Chromecast.Receiver.prototype = {
onMessage: function (event) {
if (typeof this.messageCommands[event.message.command] == 'function') {
this.messageCommands[event.message.command](event.message.content);
} else {
console.error('message unknown:', event);
}
}
};