Developing a Mini ASP.NET AJAX Server Centric Based Chat Application - A Few Words About the Timer Control
(Page 2 of 5 )
There are three ASP.NET AJAX server controls introduced to manipulate and maintain the chat application, i.e. ScriptManager, UpdatePanel and Timer. Here we're mainly interested in the Timer control, which bears the responsibility for sending the synchronous or asynchronous requests to the server at specified fixed time intervals. This control is usually used in combination with the UpdatePanel control to update some part of a page asynchronously. What's more, it can also be used to "PostBack" the whole page in regular time.
One of the important points worth noticing is that, as an Ajax control, the Timer control is different from that defined within the "System.Threading" namespace. The former is defined based upon the latter, with the main purpose of generating the client-side scripts so that the client side can send out requests to the server side on schedule.
For clearer reference, we've listed the four members of the Ajax Timer control in the table below.
Property or Event name | Description |
Enabled | Indicates whether to enable the tick event. |
Interval | Specifies the interval time. |
Tick | Specifies the task to be executed after the tick event is triggered. |
Implementing the Web Chatting Module
In this section, we will delve into the implementation of the web chat module, which mainly involves the general flow, the entity class, the login sub-module, and the main chat page, which will be examined in detail below one by one.
(1) The General Chat Flow
The chat flow is rather clear to follow. First, the user should log in and his identify should also be authenticated. Then, the user enters the chat main interface, where he can deliver his chat messages and view the current chat records and the online users. At the same time, the system will have to update the online user-related time information in good time, so that the valid online users will not be kicked out of the chat lobby. In a rough style, Figure 2 gives the related chat flow.
Figure 2-the rough chatting flow

Next, let's examine the three entity classes mention above.
(2) The Three Entity Classes
At the beginning of this article, we pointed out that the web chat room module in this sample is mainly comprised of three entity classes, i.e. the chat users, the chat information, and the chat room, where the chat room class will invoke the other two classes.
For simplicity, we've only listed the members of the above three classes in the figure form (see Figure 3, 4 and 5 below).
Figure 3-members of the ChatUser class

Figure 4-members of the Msg class

Figure 5-members of the Room class

Next: The Login Module >>
More ASP.NET Articles
More By Xianzhong Zhu