Hi Karl,
but you are still registering an UPnPEventListener with a NULL filter thus *all* UPnP devices will start to send upnpEventNotify messages to the Bridge .... the same drawbacks for the network
I was suggesting something like this pseudo code:
....
     case ServiceEvent.REGISTERED:  // listener for EventHandler
              new *EventAdminAdaptor*(event.getServiceReference());
              break;
....

public class *EventAdminAdaptor* implements UPnPEventListener {

   public EventAdminAdaptor (ServiceEvent RegisteredEventHandler)
  {
         take the EventHandlerFilter;
         register an UPnPEventListener with the same Filter;
         register a framework listener for any change of the EventHandler;
  }

public void notifyUPnPEvent(final String deviceId, final String serviceId,
       final Dictionary events)
 {
       send postEvent to the EA;
or alternatively call eventHandle of a saved m_reference to the EventHandler;
 }

public void serviceChanged(final ServiceEvent event) // listener for EventHandler changes
  {
if service is modified , update the UPnPEventListener filter if needed
      if service is unregisterd unregister the UPnPEventListener
  }

} // end EventAdminAdaptor class
in this way we pull only the required events ...
You could also registering only an instance of UPnPEventListener but you should to update its filter every time a new EventHandler is registered or modified. It ease to compose the new filter concatenating them, lesser if there are filter modification. In any case you should always create a new UPnPeventListener if there are subscriber that want to receive events from all the devices ( they would register an handler with NULL filter). A second approach is to use the same UPnPeventListener for all the handlers that use the same filter. (in the class diagram I posted these alternatives are represented by the cardinality 0..n / 0..1)

Following up the previous discussion concerning postEvent or a direct call to the eventHandle, consider that the UPnP spec already states that the uppnpEventNotify messages must be sent asynchronously so should be enough safe (uhu aha :-) ) to call directly the eventHandle ...

ciao
francesco





Karl Pauls wrote:
Hi Francesco,

I've committed the changes to trunk. Basically, the bridge now tracks
available EventAdmins and EventHandlers and registers/unregisters an
UPnPEventListener based on whether there is at least one of both
present.

regards,

Karl


Reply via email to