Пример #1
0
        /// <summary>
        /// Updates the server info for the specified serverKey
        /// </summary>
        /// <param name="serverKeyObj">string serverKey</param>
        private void UpdateServerInfo(object serverKeyObj)
        {
            string serverKey = serverKeyObj as string;

            if (serverKey == null)
            {
                return;
            }

            if (!MediaServers.ContainsKey(serverKey))
            {
                return;
            }

            ServerInfo original = MediaServers[serverKey];
            ServerInfo updated  = FetchServerInfo(original.ServerAddress);

            if (updated != null)
            {
                if (MediaServers.ContainsKey(serverKey))
                {
                    //HACK this preserves the AdvertisedService name
                    updated.ServerName = original.ServerName;

                    MediaServers[serverKey] = updated;
                    FireServerInfoChanged(serverKey);
                }
            }
            else
            {
                Debug.WriteLine("Failed to UpdateServerInfo for " + serverKey + ". Removing...");
                RemoveServer(serverKey);
            }
        }
Пример #2
0
        /// <summary>
        /// Removes a manually-added server.
        /// </summary>
        /// <param name="serverAddress">IP addres to remove</param>
        public void RemoveManualServer(string serverAddress)
        {
            string key = serverAddress + ManualDiscoverySuffix;

            if (MediaServers.ContainsKey(key))
            {
                lock (_mediaServerListLock)
                {
                    MediaServers.Remove(key);
                }
            }
        }
Пример #3
0
        /// <summary>
        /// Determines if we have previously populated the given server (by address)
        /// </summary>
        /// <param name="serverAddress">server address to check</param>
        /// <returns>Returns how the given server IP is known</returns>
        private DiscoveryMechanism IsServerKnown(string serverAddress)
        {
            bool ax     = MediaServers.ContainsKey(serverAddress);
            bool manual = MediaServers.ContainsKey(serverAddress + ManualDiscoverySuffix);

            if (ax && manual)
            {
                return(DiscoveryMechanism.Both);
            }
            else if (ax)
            {
                return(DiscoveryMechanism.AXServices);
            }
            else if (manual)
            {
                return(DiscoveryMechanism.Manual);
            }

            return(DiscoveryMechanism.NotDiscovered);
        }