Beispiel #1
0
        internal static List <String> LocalServerListThread(string ipAddress)
        {
            ServerList servers = new ServerList();

            servers = NoahServerUdpBrowser.BrowseForNoahServers(string.Empty, ipAddress).Result;
            List <String> resultList = new List <string>();

            foreach (var VARIABLE in servers.Servers)
            {
                resultList.Add(VARIABLE.FriendlyName);
            }

            return(resultList);
        }
Beispiel #2
0
        public static DiscoveryResponse Discovery(Uri resourceServerBaseAddress, string friendlyName,
                                                  ref ConnectionPreferenceType connectionpreference, string ipAddress, TimeSpan timeout)
        {
            try
            {
                Log.DebugFormat("Himsa.Noah.MobileAccessLayer.WebApi::Discovery called.");
                string path             = String.Format("api/discovery/{0}/preference/{1}", friendlyName, connectionpreference);
                var    discoveryReponse = new DiscoveryResponse {
                    RemoteHostId = Guid.Empty
                };
                if (connectionpreference == ConnectionPreferenceType.CloudOnly)
                {
                    discoveryReponse = Helpers.Get <DiscoveryResponse>(resourceServerBaseAddress, path, null, null,
                                                                       null,
                                                                       null, null, timeout);
                }
                else
                {
                    ServerList data = NoahServerUdpBrowser.BrowseForNoahServers(friendlyName, ipAddress).Result;
                    foreach (var server in data.Servers)
                    {
                        discoveryReponse = new DiscoveryResponse
                        {
                            LocalHostIpAddress = server.ServerIp,
                            RemoteHostId       = server.RemoteHostId
                        };
                    }

                    if ((connectionpreference == ConnectionPreferenceType.LocalPrefered) && (discoveryReponse.RemoteHostId == Guid.Empty))
                    {
                        discoveryReponse = Helpers.Get <DiscoveryResponse>(resourceServerBaseAddress, path, null, null,
                                                                           null,
                                                                           null, null, timeout);
                        connectionpreference = ConnectionPreferenceType.CloudOnly;
                    }
                }
                Log.DebugFormat("Himsa.Noah.MobileAccessLayer.WebApi::Discovery: {0} found.", discoveryReponse == null ? 0 : 1);
                return(discoveryReponse);
            }
            catch (Exception e)
            {
                Log.ErrorFormat("Himsa.Noah.MobileAccessLayer.WebApi::Discovery: {0}", e);
                throw;
            }
        }