mirror of
https://github.com/moonlight-stream/moonlight-chrome.git
synced 2025-08-17 16:46:31 +00:00
minor code cleaning, and more verbose logging on errors
This commit is contained in:
parent
c0e5b61425
commit
bc5e277fb1
@ -1,7 +1,3 @@
|
|||||||
// CURRENT ISSUE: host is not being saved. or it may have not been saved, and my state is screwed up.
|
|
||||||
// if (given host not in hosts) hosts.append(given host);
|
|
||||||
|
|
||||||
var _host = "";
|
|
||||||
var hosts = [];
|
var hosts = [];
|
||||||
var pairingCert;
|
var pairingCert;
|
||||||
var myUniqueid;
|
var myUniqueid;
|
||||||
@ -132,6 +128,8 @@ function pairTo(host, onSuccess, onFailure) {
|
|||||||
} else {
|
} else {
|
||||||
$('#pairingDialogText').html('Error: failed to pair with ' + host + '. failure reason unknown.');
|
$('#pairingDialogText').html('Error: failed to pair with ' + host + '. failure reason unknown.');
|
||||||
}
|
}
|
||||||
|
console.log('failed API object: ');
|
||||||
|
console.log(api.toString());
|
||||||
onFailure();
|
onFailure();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -142,11 +140,15 @@ function pairTo(host, onSuccess, onFailure) {
|
|||||||
}, function (failedPairing) {
|
}, function (failedPairing) {
|
||||||
snackbarLog('Failed pairing to: ' + host);
|
snackbarLog('Failed pairing to: ' + host);
|
||||||
console.log('pairing failed, and returned ' + failedPairing);
|
console.log('pairing failed, and returned ' + failedPairing);
|
||||||
|
console.log('failed API object: ');
|
||||||
|
console.log(api.toString());
|
||||||
onFailure();
|
onFailure();
|
||||||
});
|
});
|
||||||
}, function (failedRefreshInfo) {
|
}, function (failedRefreshInfo) {
|
||||||
snackbarLog('Failed to connect to ' + host + '! Are you sure the host is on?');
|
snackbarLog('Failed to connect to ' + host + '! Are you sure the host is on?');
|
||||||
console.log('Returned error was: ' + failedRefreshInfo);
|
console.log('Returned error was: ' + failedRefreshInfo);
|
||||||
|
console.log('failed API object: ');
|
||||||
|
console.log(api.toString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,10 +157,10 @@ function hostChosen(sourceEvent) {
|
|||||||
if(sourceEvent && sourceEvent.srcElement) {
|
if(sourceEvent && sourceEvent.srcElement) {
|
||||||
if (sourceEvent.srcElement.innerText == "") {
|
if (sourceEvent.srcElement.innerText == "") {
|
||||||
console.log('user clicked image. we gotta hack to parse out the host.');
|
console.log('user clicked image. we gotta hack to parse out the host.');
|
||||||
host = sourceEvent.currentTarget.childNodes[1].textContent;
|
var host = sourceEvent.currentTarget.childNodes[1].textContent;
|
||||||
} else {
|
} else {
|
||||||
console.log('parsing host from grid element.');
|
console.log('parsing host from grid element.');
|
||||||
host = sourceEvent.srcElement.innerText;
|
var host = sourceEvent.srcElement.innerText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,6 +174,8 @@ function hostChosen(sourceEvent) {
|
|||||||
}, function (failedRefreshInfo) {
|
}, function (failedRefreshInfo) {
|
||||||
snackbarLog('Failed to connect to ' + host + '! Are you sure the host is on?');
|
snackbarLog('Failed to connect to ' + host + '! Are you sure the host is on?');
|
||||||
console.log('Returned error was: ' + failedRefreshInfo);
|
console.log('Returned error was: ' + failedRefreshInfo);
|
||||||
|
console.log('failed API object: ');
|
||||||
|
console.log(api.toString());
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -218,7 +222,7 @@ function continueAddHost() {
|
|||||||
// this means we can re-add the host, and will still be paired.
|
// this means we can re-add the host, and will still be paired.
|
||||||
// TODO: use the chrome context menu to add right-click support to remove the host in grid-ui
|
// TODO: use the chrome context menu to add right-click support to remove the host in grid-ui
|
||||||
// https://github.com/GoogleChrome/chrome-app-samples/blob/master/samples/context-menu/main.js
|
// https://github.com/GoogleChrome/chrome-app-samples/blob/master/samples/context-menu/main.js
|
||||||
function forgetHost() {
|
function forgetHost(host) {
|
||||||
snackbarLog('Feature not yet ported to grid-ui');
|
snackbarLog('Feature not yet ported to grid-ui');
|
||||||
hosts.splice(hosts.indexOf(host), 1); // remove the host from the array;
|
hosts.splice(hosts.indexOf(host), 1); // remove the host from the array;
|
||||||
saveHosts();
|
saveHosts();
|
||||||
@ -270,12 +274,16 @@ function showApps() {
|
|||||||
|
|
||||||
}, function (failedPromise) {
|
}, function (failedPromise) {
|
||||||
console.log('Error! Failed to retrieve box art for app ID: ' + app.id + '. Returned value was: ' + failedPromise)
|
console.log('Error! Failed to retrieve box art for app ID: ' + app.id + '. Returned value was: ' + failedPromise)
|
||||||
|
console.log('failed API object: ');
|
||||||
|
console.log(api.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
}, function (failedAppList) {
|
}, function (failedAppList) {
|
||||||
console.log('Failed to get applist from host: ' + api.address);
|
console.log('Failed to get applist from host: ' + api.address);
|
||||||
|
console.log('failed API object: ');
|
||||||
|
console.log(api.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
showAppsMode();
|
showAppsMode();
|
||||||
@ -324,6 +332,8 @@ function startGame(sourceEvent) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var host = api.address;
|
||||||
|
|
||||||
// refresh the server info, because the user might have quit the game.
|
// refresh the server info, because the user might have quit the game.
|
||||||
api.refreshServerInfo().then(function (ret) {
|
api.refreshServerInfo().then(function (ret) {
|
||||||
if(api.currentGame != 0 && api.currentGame != appID) {
|
if(api.currentGame != 0 && api.currentGame != appID) {
|
||||||
@ -341,6 +351,8 @@ function startGame(sourceEvent) {
|
|||||||
}, function (failedCurrentApp) {
|
}, function (failedCurrentApp) {
|
||||||
console.log('ERROR: failed to get the current running app from host!');
|
console.log('ERROR: failed to get the current running app from host!');
|
||||||
console.log('Returned error was: ' + failedCurrentApp);
|
console.log('Returned error was: ' + failedCurrentApp);
|
||||||
|
console.log('failed API object: ');
|
||||||
|
console.log(api.toString());
|
||||||
return;
|
return;
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
@ -376,7 +388,7 @@ function startGame(sourceEvent) {
|
|||||||
streamWidth + "x" + streamHeight + "x" + frameRate,
|
streamWidth + "x" + streamHeight + "x" + frameRate,
|
||||||
1, // Allow GFE to optimize game settings
|
1, // Allow GFE to optimize game settings
|
||||||
rikey, rikeyid,
|
rikey, rikeyid,
|
||||||
remote_audio_enabled, // Play audio locally too
|
remote_audio_enabled, // Play audio locally too?
|
||||||
0x030002 // Surround channel mask << 16 | Surround channel count
|
0x030002 // Surround channel mask << 16 | Surround channel count
|
||||||
).then(function (ret) {
|
).then(function (ret) {
|
||||||
sendMessage('startRequest', [host, streamWidth, streamHeight, frameRate,
|
sendMessage('startRequest', [host, streamWidth, streamHeight, frameRate,
|
||||||
|
@ -64,7 +64,7 @@ function _base64ToArrayBuffer(base64) {
|
|||||||
var binary_string = window.atob(base64);
|
var binary_string = window.atob(base64);
|
||||||
var len = binary_string.length;
|
var len = binary_string.length;
|
||||||
var bytes = new Uint8Array( len );
|
var bytes = new Uint8Array( len );
|
||||||
for (var i = 0; i < len; i++) {
|
for (var i = 0; i < len; i++) {
|
||||||
bytes[i] = binary_string.charCodeAt(i);
|
bytes[i] = binary_string.charCodeAt(i);
|
||||||
}
|
}
|
||||||
return bytes.buffer;
|
return bytes.buffer;
|
||||||
@ -72,14 +72,34 @@ function _base64ToArrayBuffer(base64) {
|
|||||||
|
|
||||||
NvHTTP.prototype = {
|
NvHTTP.prototype = {
|
||||||
refreshServerInfo: function () {
|
refreshServerInfo: function () {
|
||||||
|
// try HTTPS first
|
||||||
return sendMessage('openUrl', [ _self._baseUrlHttps + '/serverinfo?' + _self._buildUidStr(), false]).then(function(ret) {
|
return sendMessage('openUrl', [ _self._baseUrlHttps + '/serverinfo?' + _self._buildUidStr(), false]).then(function(ret) {
|
||||||
if (!_self._parseServerInfo(ret)) {
|
if (!_self._parseServerInfo(ret)) { // if that fails
|
||||||
|
// try HTTP as a failover. Useful to clients who aren't paired yet
|
||||||
return sendMessage('openUrl', [ _self._baseUrlHttp + '/serverinfo?' + _self._buildUidStr(), false]).then(function(retHttp) {
|
return sendMessage('openUrl', [ _self._baseUrlHttp + '/serverinfo?' + _self._buildUidStr(), false]).then(function(retHttp) {
|
||||||
_self._parseServerInfo(retHttp);
|
_self._parseServerInfo(retHttp);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toString: function() {
|
||||||
|
var string = '';
|
||||||
|
string += 'server address: ' + _self.address + '\r\n';
|
||||||
|
string += 'server UID: ' + _self.serverUid + '\r\n';
|
||||||
|
string += 'is paired: ' + _self.paired + '\r\n';
|
||||||
|
string += 'supports 4K: ' + _self.supports4K + '\r\n';
|
||||||
|
string += 'current game: ' + _self.currentGame + '\r\n';
|
||||||
|
string += 'server major version: ' + _self.serverMajorVersion + '\r\n';
|
||||||
|
string += 'GFE version: ' + _self.GfeVersion + '\r\n';
|
||||||
|
string += 'gpu type: ' + _self.gputype + '\r\n';
|
||||||
|
string += 'number of apps: ' + _self.numofapps + '\r\n';
|
||||||
|
string += 'supported display modes: ' + '\r\n';
|
||||||
|
for(displayMode in _self.supportedDisplayModes) {
|
||||||
|
string += '\t' + displayMode + ': ' + _self.supportedDisplayModes[displayMode] + '\r\n';
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
},
|
||||||
|
|
||||||
_parseServerInfo: function(xmlStr) {
|
_parseServerInfo: function(xmlStr) {
|
||||||
$xml = _self._parseXML(xmlStr);
|
$xml = _self._parseXML(xmlStr);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user