fixed sync menu not displaying options

This commit is contained in:
Luke Pulverenti 2015-02-16 22:49:47 -05:00
parent 6ba570e062
commit 77578c185f
2 changed files with 38 additions and 4 deletions

View File

@ -592,14 +592,15 @@
function findServers() {
var deferred = DeferredBuilder.Deferred();
ServerDiscovery.findServers().done(function (foundServers) {
ServerDiscovery.findServers(2000).done(function (foundServers) {
var servers = foundServers.map(function (foundServer) {
return {
Id: foundServer.Id,
LocalAddress: foundServer.Address,
Name: foundServer.Name
Name: foundServer.Name,
ManualAddress: convertEndpointAddressToManualAddress(foundServer)
};
});
deferred.resolveWith(null, [servers]);
@ -607,6 +608,27 @@
return deferred.promise();
}
function convertEndpointAddressToManualAddress(info) {
if (info.Address && info.EndpointAddress) {
var address = info.EndpointAddress.split(":")[0];
// Determine the port, if any
var parts = info.Address.split(":");
if (parts.length > 1) {
var portString = parts[parts.length - 1];
if (!isNaN(parseInt(portString))) {
address += ":" + portString;
}
}
return normalizeAddress(address);
}
return null;
}
self.connect = function () {
logger.log('Begin connect');
@ -876,12 +898,19 @@
}
};
self.connectToAddress = function (address) {
function normalizeAddress(address) {
if (address.toLowerCase().indexOf('http') != 0) {
address = "http://" + address;
}
return address;
}
self.connectToAddress = function (address) {
address = normalizeAddress(address);
var deferred = DeferredBuilder.Deferred();
tryConnect(address, 15000).done(function (publicInfo) {

View File

@ -2,9 +2,14 @@
globalScope.ServerDiscovery = {
findServers: function () {
findServers: function (timeoutMs) {
var deferred = DeferredBuilder.Deferred();
var servers = [];
// Expected server properties
// Name, Id, Address, EndpointAddress (optional)
deferred.resolveWith(null, [servers]);
return deferred.promise();
}