A hosted service must implement the IUPnPEventSource interface if it has evented state variables. This interface has two methods: Advise and Unadvise. This interface provides a mechanism for the device host to subscribe to event notifications generated by the hosted service. There will be no more than one event sink registered at a time.
A hosted service must implement the Advise method by holding a reference to the IUPnPEventSink interface, which was passed as a parameter. If the interface is found, the Advise method holds a reference to that interface until Unadvise is invoked, or until the hosted service object is removed. Advise is called only once.
To remove the subscription, the device host invokes Unadvise and passes in the object pointer used when it called Advise. The hosted service removes the subscription if the pointer is the same as the one passed to Advise.
When a state variable's value changes, the hosted service must signal that an event has occurred. The services does this by invoking the IUPnPEventSink::OnStateChanged method.
When the device host no longer needs to receive notifications from the hosted service, it invokes IUPnPEventSource::Unadvise, passing in the same object pointer that it received from Advise. The device host invokes this method when the device is no longer going to be on the network.