mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
Launch the request game after quitting existing app. Fixes #72
This commit is contained in:
parent
12e34a9f4e
commit
f88f55e7c9
@ -3,6 +3,7 @@ var hosts = [];
|
|||||||
var pairingCert;
|
var pairingCert;
|
||||||
var myUniqueid;
|
var myUniqueid;
|
||||||
var api;
|
var api;
|
||||||
|
var relaunchSourceEvent;
|
||||||
|
|
||||||
// Called by the common.js module.
|
// Called by the common.js module.
|
||||||
function attachListeners() {
|
function attachListeners() {
|
||||||
@ -306,6 +307,10 @@ function startGame(sourceEvent) {
|
|||||||
api.refreshServerInfo().then(function (ret) {
|
api.refreshServerInfo().then(function (ret) {
|
||||||
if(api.currentGame != 0 && api.currentGame != appID) {
|
if(api.currentGame != 0 && api.currentGame != appID) {
|
||||||
api.getAppById(api.currentGame).then(function (currentApp) {
|
api.getAppById(api.currentGame).then(function (currentApp) {
|
||||||
|
// This event gets saved and passed back to this callback
|
||||||
|
// after the game is quit
|
||||||
|
relaunchSourceEvent = sourceEvent;
|
||||||
|
|
||||||
var quitAppDialog = document.querySelector('#quitAppDialog');
|
var quitAppDialog = document.querySelector('#quitAppDialog');
|
||||||
document.getElementById('quitAppDialogText').innerHTML =
|
document.getElementById('quitAppDialogText').innerHTML =
|
||||||
currentApp.title + ' is already running. Would you like to quit ' +
|
currentApp.title + ' is already running. Would you like to quit ' +
|
||||||
@ -333,7 +338,7 @@ function startGame(sourceEvent) {
|
|||||||
$('#loadingMessage').text('Starting ' + appName + '...');
|
$('#loadingMessage').text('Starting ' + appName + '...');
|
||||||
playGameMode();
|
playGameMode();
|
||||||
|
|
||||||
if(api.currentGame == appID) // if user wants to launch the already-running app, then we resume it.
|
if(api.currentGame == appID) { // if user wants to launch the already-running app, then we resume it.
|
||||||
return api.resumeApp(rikey, rikeyid).then(function (ret) {
|
return api.resumeApp(rikey, rikeyid).then(function (ret) {
|
||||||
sendMessage('startRequest', [host, streamWidth, streamHeight, frameRate,
|
sendMessage('startRequest', [host, streamWidth, streamHeight, frameRate,
|
||||||
bitrate.toString(), api.serverMajorVersion.toString(), rikey, rikeyid.toString()]);
|
bitrate.toString(), api.serverMajorVersion.toString(), rikey, rikeyid.toString()]);
|
||||||
@ -342,6 +347,7 @@ function startGame(sourceEvent) {
|
|||||||
console.log('Returned error was: ' + failedResumeApp);
|
console.log('Returned error was: ' + failedResumeApp);
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
api.launchApp(appID,
|
api.launchApp(appID,
|
||||||
streamWidth + "x" + streamHeight + "x" + frameRate,
|
streamWidth + "x" + streamHeight + "x" + frameRate,
|
||||||
@ -361,6 +367,7 @@ function startGame(sourceEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function cancelQuitApp() {
|
function cancelQuitApp() {
|
||||||
|
relaunchSourceEvent = null;
|
||||||
document.querySelector('#quitAppDialog').close();
|
document.querySelector('#quitAppDialog').close();
|
||||||
console.log('closing app dialog, and returning');
|
console.log('closing app dialog, and returning');
|
||||||
}
|
}
|
||||||
@ -368,7 +375,18 @@ function cancelQuitApp() {
|
|||||||
function continueQuitApp(sourceEvent) {
|
function continueQuitApp(sourceEvent) {
|
||||||
// I want the sourceEvent's sourceEvent
|
// I want the sourceEvent's sourceEvent
|
||||||
console.log('stopping game, and closing app dialog, and returning');
|
console.log('stopping game, and closing app dialog, and returning');
|
||||||
stopGame();
|
stopGame(
|
||||||
|
function() {
|
||||||
|
if (relaunchSourceEvent != null) {
|
||||||
|
// Save and null relaunchSourceEvent just in case startGame()
|
||||||
|
// wants to set it again.
|
||||||
|
var event = relaunchSourceEvent;
|
||||||
|
relaunchSourceEvent = null;
|
||||||
|
|
||||||
|
startGame(event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
document.querySelector('#quitAppDialog').close();
|
document.querySelector('#quitAppDialog').close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -404,7 +422,6 @@ function fullscreenNaclModule() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function stopGame(callbackFunction) {
|
function stopGame(callbackFunction) {
|
||||||
|
|
||||||
api.refreshServerInfo().then(function (ret) {
|
api.refreshServerInfo().then(function (ret) {
|
||||||
api.getAppById(api.currentGame).then(function (runningApp) {
|
api.getAppById(api.currentGame).then(function (runningApp) {
|
||||||
if (!runningApp) {
|
if (!runningApp) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user