From 02341e85e2a1dff9b1e05b42f55329bc8adcd326 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Thu, 10 Mar 2016 22:29:00 -0800 Subject: [PATCH] Add basic logic for resuming an existing stream --- static/js/index.js | 9 ++++++++- static/js/utils.js | 8 ++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/static/js/index.js b/static/js/index.js index 6c9c45d..799873a 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -107,8 +107,15 @@ function startPushed() { console.log('startRequest:' + target + ":" + streamWidth + ":" + streamHeight + ":" + frameRate + ":" + bitrate); - sendMessage('startRequest', [target, streamWidth, streamHeight, frameRate, bitrate.toString()]); sendMessage('httpInit', [pairingCert.cert, pairingCert.privateKey, myUniqueid]).then(function (ret) { + api = new NvHTTP(target, myUniqueid); + api.init().then(function (ret) { + if (api.currentGame != 0) { + api.resumeApp('00000000000000000000000000000000', 0).then(function (ret) { + sendMessage('startRequest', [target, streamWidth, streamHeight, frameRate, bitrate.toString()]); + }); + } + }); }); // we just finished the gameSelection section. only expose the NaCl section diff --git a/static/js/utils.js b/static/js/utils.js index 842d4d9..fd075ac 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -39,8 +39,8 @@ NvHTTP.prototype = { $root = $xml.find('root') if($root.attr("status_code") == 200) { - _self.pair = getXMLString(xml, "PairStatus").trim() == 1; - _self.currentGame = getXMLString(xml, "currentgame").trim(); + _self.paired = $root.find("PairStatus").text().trim() == 1; + _self.currentGame = parseInt($root.find("currentgame").text().trim(), 10); } }); }, @@ -93,7 +93,7 @@ NvHTTP.prototype = { }); }, - launchApp: function (context, appId, mode, sops, rikey, rikeyid, localAudio, surroundAudioInfo) { + launchApp: function (appId, mode, sops, rikey, rikeyid, localAudio, surroundAudioInfo) { return sendMessage('openUrl', [ _self.baseUrlHttps + '/launch?' + _self._buildUidStr() + @@ -109,7 +109,7 @@ NvHTTP.prototype = { }); }, - resumeApp: function (context, rikey, rikeyid) { + resumeApp: function (rikey, rikeyid) { return sendMessage('openUrl', [ _self._baseUrlHttps + '/resume?' + _self._buildUidStr() +