Update July 30th 2011: The source code can now be downloaded in an updated version from here: https://github.com/maate/OCometNet.
This post contains the source code for the comet project (url: https://retkomma.wordpress.com/2009/08/05/server-to-client-notification-using-asp-net-and-comet-approach/).
The download link is at the bottom of this post. The code structure is described first.
How to run the test project
Open in Visual Studio and hit F5 to open Default.aspx page. Now the entries in the xml file notifications.xml will be displayed in the browser. Has been tested with IE only, but will probably work with other browsers as well.
The figure below presents a brief overview of the solution design. The solution has been implemented sparsely, but with some limits. The code is not compiled and can thus be reviewed if the project library is downloaded.
The code contains the logical mappings:
|Name in the figure above||Code mapping|
Processing from MessageBroker occurs using AsyncResult.cs class.
|Message Queue Database||Not implemented, stub created in notifications.xml|
|Business Module N||Not implemented, can be simulated by using the stub in notifications.xml|
The figure is shortly described here:
1 to 3: Client submits user handle
1. The client sends a user handle to notificationchecker.ashx.
2. NotificationChecker.ashx sends the handle to the messagebroker.
3. The message broker registers the user handle.
A to C: A business module N submits a notification message to user U
A. Some module submits a notification message to the message broker.
B. The message broker queues the message.
C. The message broker processes the message queue.
D to E: The message broker processes the message queue
D. The message broker checks if the user has submitted a handle. If she has, the user handle is released.
E. The message broker releases the response to the client
F to H: The client acknowledges the notification response
F. Client sends notification acknowledgement to NotificationAcknowledger.ashx.
G. NotificationAcknowledger sends acknowledgement to MessageBroker which finally removes message from repository.
H. The Message Broker sends a 200 (OK) response back to the client
Download the code from: http://www.box.net/shared/nbp04r1ujs