Changeset 131

Show
Ignore:
Timestamp:
03/05/07 21:26:02 (2 years ago)
Author:
blunard2
Message:

Tiny move for gui initiated service dicoveries

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dmp/trunk/Bridge/Bridge.cs

    r124 r131  
    2323        private BridgeDatabase db; 
    2424 
     25        private bool myServiceLocatorStarted; 
     26 
    2527                /// <summary> 
    2628                /// Discovers servers 
     
    3436            clientList = new Dictionary<int, Client>(); 
    3537            db = new BridgeDatabase(); 
    36                         this.myServiceLocator = new ServiceLocator(); 
    37                         this.myServiceLocator.ShowLocalServices = true; 
    38                         this.myServiceLocator.Start(); 
    39                         DataTable dbServers = db.getServersInCollection(); 
    40                         System.Threading.Thread.Sleep(2000); 
    41                         Dictionary<String, Service> whatDAAPFound = this.getZeroconfServerList(); 
    42                         foreach (DataRow row in dbServers.Rows) { 
    43                                 string serverName = (string) row["name"]; 
    44                                 Console.WriteLine("Trying to connect to " + serverName); 
    45                                 if (whatDAAPFound.ContainsKey(serverName)) { 
    46                                         Service newServer = whatDAAPFound[serverName]; 
    47                                         this.AddServerConnection(newServer); 
    48                                 } 
    49                                 else { 
    50                                         Console.WriteLine("Couldn't find " + serverName); 
    51                                 } 
    52                         } 
    53                 } 
     38            this.myServiceLocator = new ServiceLocator(); 
     39            this.myServiceLocator.ShowLocalServices = true; 
     40            this.myServiceLocatorStarted = false; 
     41                } 
     42 
     43 
     44        /// <summary> 
     45        /// Starts the service locator if it has not been started. Performs service locating 
     46        /// to connect to new servers. 
     47        /// </summary> 
     48        public void performServiceLocation() 
     49        { 
     50            if (!this.myServiceLocatorStarted) 
     51            { 
     52                this.myServiceLocatorStarted = true; 
     53                this.myServiceLocator.Start(); 
     54            } 
     55             
     56            DataTable dbServers = db.getServersInCollection(); 
     57            System.Threading.Thread.Sleep(2000); 
     58            Dictionary<String, Service> whatDAAPFound = this.getZeroconfServerList(); 
     59            foreach (DataRow row in dbServers.Rows) 
     60            { 
     61                string serverName = (string)row["name"]; 
     62                Console.WriteLine("Trying to connect to " + serverName); 
     63                if (whatDAAPFound.ContainsKey(serverName)) 
     64                { 
     65                    Service newServer = whatDAAPFound[serverName]; 
     66                    this.AddServerConnection(newServer); 
     67                } 
     68                else 
     69                { 
     70                    Console.WriteLine("Couldn't find " + serverName); 
     71                } 
     72            } 
     73        } 
     74 
    5475                /// <summary> 
    5576                /// Connects to the given server and eventually will get the songs from it 
     
    96117                                libraryCount++; 
    97118                        } 
     119 
    98120                        DataTable theTable = this.db.getAvailableSongsInCollection(libraries); 
    99121                        return theTable;