How to Make a Web Messaging Client via ASPBy 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|
|Online||Number (I don't boolean because I have trouble in my ver of Access ;-)|
The second looks like this:
|User List Information Table|
|OwnerID||Foreign key to UserID in the User Inf table|
|UserID||Foreign 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!):
| I |
|z c v b|
Explanation of letters:
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 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!
This article was written by
Ryan has been a computer programmer
in the loosest sense since the age of 8. He has been working with ASP
since the age of 13, when it first came out (that he knows of), and is
somewhat advanced at it.