added backend support for storing varios addressing methods of hosts

This commit is contained in:
R. Aidan Campbell 2016-07-26 15:20:24 -04:00
parent a09b5e7ea9
commit 853d061acb
2 changed files with 12 additions and 7 deletions

View File

@ -211,7 +211,7 @@ function addHostToGrid(host) {
function continueAddHost() { function continueAddHost() {
var inputHost = $('#dialogInputHost').val(); var inputHost = $('#dialogInputHost').val();
var nvhttpHost = new NvHTTP(inputHost, myUniqueid); var nvhttpHost = new NvHTTP(inputHost, myUniqueid, inputHost);
pairTo(nvhttpHost, pairTo(nvhttpHost,
function() { function() {
addHostToGrid(nvhttpHost); addHostToGrid(nvhttpHost);
@ -603,11 +603,11 @@ function onWindowLoad(){
storeData('uniqueid', myUniqueid, null); storeData('uniqueid', myUniqueid, null);
} }
}); });
// load previously connected hosts, and revive them back into a class // load previously connected hosts, which have been killed into an object, and revive them back into a class
chrome.storage.sync.get('hosts', function(previousValue) { chrome.storage.sync.get('hosts', function(previousValue) {
hosts = previousValue.hosts != null ? previousValue.hosts : {}; hosts = previousValue.hosts != null ? previousValue.hosts : {};
for(hostUID in hosts) { // programmatically add each new host. for(hostUID in hosts) { // programmatically add each new host.
var revivedHost = new NvHTTP(hosts[hostUID].address, myUniqueid); var revivedHost = new NvHTTP(hosts[hostUID].address, myUniqueid, hosts[hostUID].userEnteredAddress);
revivedHost.serverUid = hosts[hostUID].serverUid; revivedHost.serverUid = hosts[hostUID].serverUid;
revivedHost.externalIP = hosts[hostUID].externalIP; revivedHost.externalIP = hosts[hostUID].externalIP;
revivedHost.hostname = hosts[hostUID].hostname; revivedHost.hostname = hosts[hostUID].hostname;
@ -621,7 +621,13 @@ function onWindowLoad(){
var ips = Object.keys(finder.byService_['_nvstream._tcp']); var ips = Object.keys(finder.byService_['_nvstream._tcp']);
for (var ip in ips) { for (var ip in ips) {
if (finder.byService_['_nvstream._tcp'][ip]) { if (finder.byService_['_nvstream._tcp'][ip]) {
addHostToGrid(new NvHTTP(ip, myUniqueid)); var mDnsDiscoveredHost = new NvHTTP(ip, myUniqueid);
if(hosts[mDnsDiscoveredHost.serverUid] != null) {
// if we're seeing a host we've already seen before, update it for the current local IP.
hosts[mDnsDiscoveredHost.serverUid].localIp = mDnsDiscoveredHost.localIp;
} else {
addHostToGrid(mDnsDiscoveredHost);
}
} }
} }
} }

View File

@ -31,10 +31,9 @@ String.prototype.toHex = function() {
return hex; return hex;
} }
function NvHTTP(address, clientUid) { function NvHTTP(address, clientUid, userEnteredAddress = '') {
this.address = address; this.address = address;
this.paired = false; this.paired = false;
this.supports4K = false;
this.currentGame = 0; this.currentGame = 0;
this.serverMajorVersion = 0; this.serverMajorVersion = 0;
this.clientUid = clientUid; this.clientUid = clientUid;
@ -42,6 +41,7 @@ function NvHTTP(address, clientUid) {
this._baseUrlHttp = 'http://' + address + ':47989'; this._baseUrlHttp = 'http://' + address + ':47989';
this._memCachedBoxArtArray = {}; this._memCachedBoxArtArray = {};
this.userEnteredAddress = userEnteredAddress; // if the user entered an address, we keep it on hand to try when polling
this.serverUid = ''; this.serverUid = '';
this.GfeVersion = ''; this.GfeVersion = '';
this.supportedDisplayModes = {}; // key: y-resolution:x-resolution, value: array of supported framerates (only ever seen 30 or 60, here) this.supportedDisplayModes = {}; // key: y-resolution:x-resolution, value: array of supported framerates (only ever seen 30 or 60, here)
@ -90,7 +90,6 @@ NvHTTP.prototype = {
string += 'server address: ' + _self.address + '\r\n'; string += 'server address: ' + _self.address + '\r\n';
string += 'server UID: ' + _self.serverUid + '\r\n'; string += 'server UID: ' + _self.serverUid + '\r\n';
string += 'is paired: ' + _self.paired + '\r\n'; string += 'is paired: ' + _self.paired + '\r\n';
string += 'supports 4K: ' + _self.supports4K + '\r\n';
string += 'current game: ' + _self.currentGame + '\r\n'; string += 'current game: ' + _self.currentGame + '\r\n';
string += 'server major version: ' + _self.serverMajorVersion + '\r\n'; string += 'server major version: ' + _self.serverMajorVersion + '\r\n';
string += 'GFE version: ' + _self.GfeVersion + '\r\n'; string += 'GFE version: ' + _self.GfeVersion + '\r\n';