Skip to content

Commit

Permalink
save
Browse files Browse the repository at this point in the history
  • Loading branch information
Wesley Yee committed Nov 1, 2017
1 parent e2b8332 commit 7a52f48
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 5 deletions.
19 changes: 19 additions & 0 deletions lib/controllers/classpass.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var util = require('util');
var debug = require('debug')('castv2-client');
var JsonController = require('./json');

function ClassPassController(client, sourceId, destinationId) {
JsonController.call(this, client, sourceId, destinationId, 'urn:x-cast:classpass.video');

this.on('message', onmessage);

var self = this;

function onmessage(data, broadcast) {
console.log('data', data);
}
}

util.inherits(ClassPassController, JsonController);

module.exports = ClassPassController;
10 changes: 7 additions & 3 deletions start.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const Client = require('./lib/senders/platform');
const DefaultMediaReceiver = require('./lib/senders/default-media-receiver');
const ClassPassController = require('./lib/controllers/classpass');
const mdns = require('mdns');
const co = require('co');
const dal = require('./dal');
Expand Down Expand Up @@ -34,6 +35,8 @@ co(function* () {
function ondeviceup(host) {

const client = new Client();
const controller = client.createController(ClassPassController);
const cpController = new Controller(controller, 'sender-0', 'receiver-0', 'urn:x-cast:classpass.video');

client.connect(host, function() {
console.log('connected, launching app ...');
Expand Down Expand Up @@ -64,12 +67,13 @@ co(function* () {
console.log('app "%s" launched, loading media %s ...', player.session.displayName, media.contentId);

player.load(media, { autoplay: true }, function(err, status) {
player.play();
console.log('media loaded playerState=%s', status.playerState);
controller.send({
pusher_channel,
user_id: userId,
});
});

});

});

client.on('error', function(err) {
Expand Down
8 changes: 6 additions & 2 deletions stop.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
const co = require('co');
const dal = require('./dal');
const co = require('co');
const mdns = require('mdns');
const dal = require('./dal');

// setup
co(function* () {
try {
const browser = mdns.createBrowser(mdns.tcp('googlecast'));
browser.stop();

const alias = 'chromecast-only'
yield dal.endClass(alias);
yield dal.deleteClass(alias);
Expand Down

0 comments on commit 7a52f48

Please sign in to comment.