Source code for comet project

Update July 30th 2011: The source code can now be downloaded in an updated version from here:


This post contains the source code for the comet project (url:

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.

Solution design

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
Client Default.aspx
NotificationChecker.ashx Endpoint:NotificationChecker.ashxBackend: AsyncTaskHandler.cs

Processing from MessageBroker occurs using AsyncResult.cs class.

MessageBroker MessageBroker.cs
Message Queue MessageBrokerRepository.cs
Message Queue Database Not implemented, stub created in notifications.xml
UserHandle AsyncRequestResult.cs
Business Module N Not implemented, can be simulated by using the stub in notifications.xml
NotificationAcknowledge.ashx Not implemented

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:


12 responses to “Source code for comet project

  1. Pingback: Server to Client notification using ASP.NET with Comet Approach « Linguistic forms

  2. Hi,

    We have downloaded your code and tried to modify according to our requirement. We implemented sender and receiver part in a single page. Problem is when I am tring to send message by clicking on button “Send notification” when there is no message in queue it goes in requesting mode.
    Can you please share your email id so that I can send you the code?

    Thanks & Regards,

  3. Hi,
    I have also downloaded the source.
    i just tried the basic example it works right.
    but I have encountered problems when refreshing AddNotification page think IIS is taking long time to serve other pages hosted in same directory, once notification is served to client.
    To reproduce the same,try sending msgs from
    AddNotification page(i tried using AJAX to send data to AddNotification ) ..but after few requests IIS gets very slow serving request for
    AddNotification page..takes atleast 1-2mins for the AddNotification page to load.
    Strangely if u refresh Default.aspx the
    AddNotification page appears.

    Dunno the reason why?
    Please help


  4. Hi, it seems the download link for your project is broken.
    It would be great if you can have it fixed or re-upload the zip file.


  5. Download the code from:

    i can’t download code on that link. Plz fake that link.

    Tks so much!

  6. So, finally I succeeded in fixing the broken link – sorry for the inconvenience 🙂

  7. i am getting item with the same key has already been added…please help i need this working urgently….

  8. I have started working on a production ready version of the comet source code. You can follow – and contribute! – to my work here:

    I’m not finished yet, but I expect at least a first version to be ready within a few months.

  9. Hope to see the full version of your Comet when ready. Update this blog or send me an email when you hit 1.0!

  10. The source code can now be downloaded in an updated version from here: I’m still not ready for a 1.0, but it is much better than the old stuff.

  11. It is not running through vs2010.Any body can help me to run this.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s