To read the article online, visit

How to Make a Web Messaging Client via ASP

By Ryan S.

First, what are the benifits of this? Here are some -

  • Intranets can have messaging features w/ their extranets, eliminating the need to setup tricky proxy settings or servers
  • Schools can add messaging features for the students in the computer labs
  • People behind unfriendly proxies (company, libraries, ect, where users aren't allowed to tinker with the settings) can use these messaging features.
  • This is an outline on how to create any form of messaging clients for ASP. I don't go directly in the code, although I might go into it later. Heres how it looks. -

    Let's say you want to create a web site with features like, say AOL Instant Messenger (tm of America Online, Inc). You wan to be able to have a user list of who is online, be able to send messages, set away messages, etcetera. You will have a page load up in the main browser which is a logon page. This page gets username/password, and checks the validity in the database. If it is valid, then it loads a seperate window with an ASP page.

    This ASP page is set to refresh every 30 seconds. It will contact the SQL server, query to see if the people in the users list match the people marked online. This is done via two tables. The first table looks like this

    User Information Table
    OnlineNumber (I don't boolean because I have trouble in my ver of Access ;-)

    The second looks like this:

    User List Information Table
    OwnerIDForeign key to UserID in the User Inf table
    UserIDForeign Key to UserID in the User Inf Table

    That's it for those. While I recognize I don't fully discuss the table creation, I left it open for people who want to add/change fields such as phone number, email, etc.

    OwnerID is the ID of the user who has the list. UserID is the ID of the user on the list. This way, you can have an unlimited number of OwnerIDs and UserIDs. I didn't declare a primary key because it's not really nessicery, but you could create an extra field if you wanted to take up space.

    Now that you understand the layout of the table, lets discuss the layout of the page. Here is a rough image (screen shots on the way!):

    |A      |
    | I     |
    |xI     |
    |z c v b|

    Explanation of letters:

  • A - Users online. It looks like this "Friends ((count of users who are online and in list) of (count of users in list)) - Example - Friends (1 of 3)
  • I - A UserName of a user who is online
  • xI - x is a flag visually marking that the user is away. I is the username.
  • z c v b are commands like Edit UserList, Send Message (if the user is perhaps not in your list), Prefrences, ect

    You could also include a banner ad if you wanted to do it for profit (if you do, talk to me, cause I want to help, cause i need $$$ =D) Now that you understand how that looks, you create a new window to send a message. It would be a frame set, looking like this: (screen shots on the way!)

    |      |
    |      |

    The top frame contains a text box of who you are going to send a message to. This value will be pulled out using javascript when the submit button is pressed. Next, the middle frame has formatted text of all the messages, to and from the users w/ a scroll bar. Finally, the bottom frame has a multiline text box of the message you will be sending, and a submit button.

    When the user clicks the submit button, client side JavaScript will verify that neither the user name or message field is empty. If it is, cancels submitting. If not, it will fill the data values into the bottom frame to ensure that it is set. Then, it does the actual submit action.

    The submit action adds the message to the message database, marking the UserNames (perhaps utilize the UserName as the primary key, because you should not have multiple user names) of the sender and recipient, the date (now()) of the message, and the actual message (where all vbCrLf have been replaced w/ <br>).

    The messaging window center frame will update itself every 10 seconds. This could cause a high load on the server, so the option for the users to select the rate of update (which will then be stored in session variables and the database) could be changed (with a minimum # of seconds)

    Finally, the main window updates itself perhaps every 30 seconds. Each time it does so, it marks the latest update. Then, the ASP page would check if the latest update was greater than 5 minutes ago. If it is, it marks the user as away. Also, when the away button is pressed, the rate of change is changed from 30 seconds to 1 and 1/2 minutes. Then, if the user still doesn't update after 10 minutes (because he/she has closed the window) then they are marked as offline.

    This is all automated, and will be executed on the server's end. It would probably be a good idea to schedule the execution of runDLL32 executing a DLL subroutine which does these matinence features every 3 minutes. Keeps the clients from hitting the server really hard.

    Thus, I am done writing this tutorial. I only discussed theory, obviously. Theory is what is important, though. Syntax is merely semantics; understanding the ideas behind an application is what is important!

    Happy Programming!

  • Article Information
    Article Title: How to Make a Web Messaging Client via ASP
    Article Author: Ryan S.
    Published Date: Thursday, April 29, 1999
    Article URL:

    Copyright 2019 QuinStreet Inc. All Rights Reserved.
    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers