Changeset 164

Show
Ignore:
Timestamp:
03/09/07 01:33:01 (2 years ago)
Author:
kbarnes3
Message:

Fixed discoverability by properly casting an int.

Files:

Legend:

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

    r159 r164  
    1414                        InitializeComponent(); 
    1515                        myBridge = new Bridge(); 
     16            myBridge.StartZeroConf(); 
    1617            if( myBridge.isDatabaseUp() ) 
    1718                lblStatus.Text = "Status: Bridge constructed and db up!"; 
  • dmp/trunk/Bridge/Bridge.cs

    r156 r164  
    1616        { 
    1717                /// <summary> 
    18                 /// Fires when a new server is connecte
     18                /// Fires when a new server is foun
    1919                /// </summary> 
    2020                public event EventHandler<ServerStatusEventArgs > ServerAdded; 
    2121 
    2222                /// <summary> 
    23                 /// Fires when a server is disconnected 
     23                /// Fires when a server is lost 
    2424                /// </summary> 
    2525                public event EventHandler<ServerStatusEventArgs> ServerRemoved; 
     26 
     27                /// <summary> 
     28                /// Fires when a server is connected or disconnected 
     29                /// </summary> 
     30                public event EventHandler<ServerStatusEventArgs> ServerStatusChanged; 
    2631 
    2732                /// <summary> 
     
    284289 
    285290 
    286                                 if (this.ServerAdded != null) { 
    287                                         this.ServerAdded(this, new ServerStatusEventArgs(newClient.Name, true)); 
     291                                if (this.ServerStatusChanged != null) { 
     292                                        this.ServerStatusChanged(this, new ServerStatusEventArgs(newClient.Name, true)); 
    288293                                } 
    289294 
     
    313318                                this.db.RemoveServer(libraryId); 
    314319                                DataTable newTable = this.getAvailableSongsInCollection(); 
    315                                 this.ServerRemoved(this, new ServerStatusEventArgs(oldClient.Name, false)); 
    316                                 this.SongListChanged(this, new SongListChangedEventArgs(newTable)); 
     320                                if (this.ServerStatusChanged != null) { 
     321                                        this.ServerRemoved(this, new ServerStatusEventArgs(oldClient.Name, false)); 
     322                                } 
     323                                if (this.SongListChanged != null) { 
     324                                        this.SongListChanged(this, new SongListChangedEventArgs(newTable)); 
     325                                } 
    317326                                return true; 
    318327                        } 
     
    345354                private void ZeroConfServerFound(object o, DAAP.ServiceArgs args) { 
    346355                        Service newServer = args.Service; 
     356                        Console.WriteLine("ZeroConf found " + newServer.Name); 
    347357                        int libraryId = this.db.getLibraryIdForName(newServer.Name); 
     358                        Console.WriteLine("Library ID for " + newServer.Name + " is " + libraryId); 
    348359                        if (libraryId > -1) { //Reconnect to this server 
    349360                                int addResult = this.AddServerConnection(newServer); 
    350                                 if (addResult <= -1) { //Connect failed 
     361                                if (addResult > -1) { //Connected 
    351362                                        if (this.ServerAdded != null) { 
     363                                                this.ServerAdded(this, new ServerStatusEventArgs(newServer.Name, true)); 
     364                                        } 
     365                                        else { //Connection failed 
    352366                                                this.ServerAdded(this, new ServerStatusEventArgs(newServer.Name, false)); 
    353367                                        } 
  • dmp/trunk/Mono.Zeroconf/BrowseService.cs

    r155 r164  
    131131                        break; 
    132132                    } 
    133                                         try { 
    134                                                 IPAddress address = new IPAddress(Marshal.ReadInt32(rdata)); 
     133                                        Int64 temp = (Int64) Marshal.ReadInt32(rdata); 
     134                                        temp &= 0x00000000FFFFFFFF; 
     135                                        IPAddress address = new IPAddress(temp); 
    135136 
    136                                                if (hostentry == null) { 
    137                                                        hostentry = new IPHostEntry(); 
    138                                                        hostentry.HostName = hosttarget; 
    139                                                
     137                                        if (hostentry == null) { 
     138                                                hostentry = new IPHostEntry(); 
     139                                                hostentry.HostName = hosttarget; 
     140                                       
    140141 
    141                                                if (hostentry.AddressList != null) { 
    142                                                        ArrayList list = new ArrayList(hostentry.AddressList); 
    143                                                        list.Add(address); 
    144                                                        hostentry.AddressList = list.ToArray(typeof(IPAddress)) as IPAddress[]; 
    145                                                
    146                                                else { 
    147                                                        hostentry.AddressList = new IPAddress[] { address }; 
    148                                                
     142                                        if (hostentry.AddressList != null) { 
     143                                                ArrayList list = new ArrayList(hostentry.AddressList); 
     144                                                list.Add(address); 
     145                                                hostentry.AddressList = list.ToArray(typeof(IPAddress)) as IPAddress[]; 
     146                                       
     147                                        else { 
     148                                                hostentry.AddressList = new IPAddress[] { address }; 
     149                                       
    149150 
    150                                                 EventHandler handler = Resolved; 
    151                                                 if (handler != null) { 
    152                                                         handler(this, new EventArgs()); 
    153                                                 } 
    154                                         } 
    155                                         catch (ArgumentOutOfRangeException e) { 
    156                                                 //I don't care 
     151                                        EventHandler handler = Resolved; 
     152                                        if (handler != null) { 
     153                                                handler(this, new EventArgs()); 
    157154                                        } 
    158155                    break;