Publisher Characteristics (Windows CE 5.0)
The device-side publisher is a dynamic-link library (DLL) that exposes a Component Object Model (COM) object. The COM object implements the IPublisher interface. The publisher lives inside the lifetime of one or more subscribers. The publisher's lifetime begins when the first subscriber registers. When the count of subscribers for a specified publisher reaches zero, the publisher unloads. When the count of subscriber sessions across all publishers reaches zero for a specified device, the connection to the device is terminated.
The device-side publisher gathers data and sends it to the object on the desktop computer that implements the IPublishSubscribeMgr interface. This object, also known as the subscriber service, facilitates communication between data publishers and subscribers. The publisher can receive control messages from subscribers or broadcast state-change data to subscribers.
The publisher enables buffering and sets the maximum buffer size during its initialization. Then, the subscriber service creates a circular buffer for the publisher that grows to a maximum size, if needed. The buffer might overflow because the publisher writes to the buffer and the subscriber service reads from the buffer asynchronously. If the buffer overflows, data from the publisher is discarded until the subscriber service reads sufficient data. The subscriber service notifies the publisher and all registered subscribers of data loss.
If the publisher disables buffering, each publisher call to write data does not return until all registered subscribers receive the data.
When a publisher is initialized, it can broadcast messages. The subscriber service receives messages from the publisher and places them in a buffer. When a publisher's message enters the buffer, the publisher's call to the subscriber service returns successfully. The subscriber service then calls the ISubscriber::Write method for each registered subscriber.
For an example of a custom publisher, see the Hello Publisher sample in Publish/Subscribe Samples.
Send Feedback on this topic to the authors