xiaoyanit / upnpx

Automatically exported from code.google.com/p/upnpx
0 stars 0 forks source link

UPnPDBObserver: change semantics to get explicit 'deviceAdded' or 'deviceRemoved' calls #13

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I think those "dbUpdated" notification are really cumbersome to handle.

If one wants to know exactly what happend (what device actually was added or 
removed) one has to write extra code to find out. And I think its not too 
uncommon to want to find out the added devices.

Why isn't the Observer told explicitly what device was added or removed? This 
would make client code much much easier to write.

Attached you will find a proposed patch for the UPnPObserver. Note that it is 
not backwards compatible, as it removes the old notifications.
As UPnPDB still has a list of all devices - consumers that are just interested 
in the list, could still just access it, when one of the callbacks is called.

Please note that the same change could also be applied one level deeper 
(SSDPDB). It would make the code in UPnPDB:SSDPDBUpdated much much easier, if 
you didn't have to compare a previous state with the current state, just to 
calculate, what devices where added (and need to download the description) vs. 
the ones removed.

Original issue reported on code.google.com by bluegasp...@gmail.com on 17 Jul 2012 at 10:11

Attachments: