AjaxMethodCallback Chat

Home Home | Reset Page Reset Page | Page created: 5/23/2012 8:54:45 AM
Messages:

Enter a Message:
Your Chat Handle:
Enter a Chat Id:

Active Users:


This example demonstrates using the AjaxMethodCallback control to an HTTP handler that implements the Chat Message service functionality. There's no code in the server page at all except for initial assignment of chat id and forum. All other code retrieves data from the Ajax Service Handler.

The majority of the code sits on the client side. This code uses the client proxy to make calls to the server and update the controls on the page.

Since AJAX cannot reliably do a PUSH model the only way for the client to get the latest messages is to poll the server for updates frequently. Therefore this is a very chatty interface that fires a lot of requests to the server. Load with many users in this scenario could very easily become a scalability problem. However, this example uses pure JSON messages which push only updated data back and forth so message size generally is very small. You might want to break out Fiddler and compare both the ATLAS and Anthem chat which use different approaches, where this approach is the more bandwidth friendly of the two.