Subscribing to Events
// Add event source DpwsWseEventSource sampleEvent = new DpwsWseEventSource("smpl", "http://schemas.example.org/SampleService", "SampleEvent"); EventSources.Add(sampleEvent);
To send an event, use the Dpws.Device.Services.DpwsWseSubscriptionMgr.FireEvent method. This method requires a reference to the DpwsHostedService, a reference to the DpwsWseEventSource, and a byte array containg the SOAP message to be sent. The latter is typically constructed by a method in the service, using System.Ext.Xml.XmlWriter.
The following is an example of raising an event SampleEvent in the service SampleService, assuming references to the service and the event source were stored in the variables sampleService and sampleEvent when they were instantiated, as shown in the last code sample:
// build the message and fire the event Dpws.Device.Services.DpwsWseSubscriptionMgr.FireEvent(sampleService, sampleEvent, sampleService.BuildSampleEventMessage());