CustomNotification

CustomNotification is a sample that defines an example of a derived class of TNotification, TLongNotification. It extends TSender to issue the TLongNotification, and TReceiver to handle it.

Running the sample

Execute CustomNotificationSApp. As the notifications are sent and received, a series of values appear in the shell window. Because the notification carries the old value, when the receiver handles the notification, it displays both the old value and the current one.

Files and classes

TSender is defined in Sender.h and Sender.C. It documents in some form (in this sample, by a comment in the header file) that the class of notification sent with a particular interest is a TLongNotification. When it sends out notification, it creates and issues a TLongNotification instead of a TNotification.

TReceiver is defined in Receiver.h and Receiver.C. It coerces the received notification to the derived class that it knows the sender will send, and extracts pertinent information from it.

TLongNotification is defined in LongNotification.h and LongNotification.C. It derives TNotification to carry a data value.

Notes

TNotifications must be streamable across address spaces. In this case the value field, a long, is trivially streamable. Notifications containing subobjects typically must flatten and resurrect the objects.

This kind of notification allows the receiver to know more information about the state of the sender at the time the notification was sent. Even with synchronous notification, previous receivers might have changed the state of the sender before this receiver receives the notification.


Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.