Building a simple chatroom

By ServerWatch Staff (Send Email)
Posted Jun 18, 1998

Paul Smullen
Building a simple chat room using ASP is just that - Simple.

Chat rooms make a good example of when to use local, Session and Application level variables.
The chat room in this example uses a frameset with four frames;

  • An advertisement frame
  • Messages/Chat frame
  • Login/post message frame
  • Application Status frame

    Advertisement Frame
    A place to put an advertisement banner or a link back to your main site.

    Messages/Chat Frame
    This frame shows all messages posted and who posted them.

    Login/post message Frame
    Before you can post a message you must sign on or log in. This is just an alias that you can be identified as by other users. There is no tracking of user's details carried out.

    Application Status Frame
    This shows the date and time of the last message posted and a list of people who are currently signed on.

    Coding Outline...
    Two Application arrays exists

  • Users - holds the names of all users logged on.
  • Messages - holds the latest n messages.

    When a user signs on, they are added to the Users array. The contents of this array are displayed in the Status frame which is refreshed at a set interval.

    When the user logs off they are removed from the array.

    When the user posts a message it is added to the message array and displayed in the Message frame.

    Building a simple chat room using ASP is just that - Simple.

    See it in action...
    This is running here if you want to see how it works.

    Download sample code...
    Download a ZIP file containing the ASP pages for this applications.

    Feel free to contact me by e-mail if you have any queries.

  • Page 1 of 1

    Comment and Contribute

    Your name/nickname

    Your email

    (Maximum characters: 1200). You have characters left.



    Thanks for your registration, follow us on our social networks to keep up-to-date