15.4. Another full example

This scenario involves three consumers and two events from the same event source. Two of the consumers will be listening to the same event, while the third consumer will be monitoring another event.

In this example, a WaterTank (the event source) fills up slowly. Two interested consumers, the EmergencyAlarm and the FlashingLight, want to be notified when the water level reaches 20 m so that they can start ringing and flashing to attract attention. The warnings are supposed to prompt the duty officer to rush over, pump out the water manually, and turn off the alarm and light. If he has had too much alcohol the night before and does not respond to the din, an Electrode (somehow attached to his body) should fire small ...

Get From Java to C#: A Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.