Develop chat rooms with JavaScript and XML in ASP

Source: Internet
Author: User

Program code


Introduction:
Here I have added the User License Agreement and registration information. The visitor chat is upgraded to a registered chat and the confirmation of the license agreement is added. New users must be registered. Registered users must log in with their usernames and passwords.
Registration chat:
On the start page, you need to add a password area and a button to connect to the registration page. The login function is used to append the password determination function. In this function, replace the user name and password with the repeated registration check. If the user name and password are correct, a new dialog is created. User-introduced functions include (nickname, password, last name, name, email ). The two functions use a single storage method. Why is it an XML file or a related database. XML is used here.
For operational reasons, XML data must always exist in the memory, and disk I/O operations should rarely occur. A shared XML class previously written meets this need with minor changes. Only two functions are added: Save (filename) and load (filename) to read and write XML. To access a single node attribute, use the userinfo class. To achieve a good design architecture, the userdataxml class is used, which encapsulates sharedxml and userinfo classes.
The data algorithm is as follows:
Data Loading
Initial data load must be on application startup or on First Data Access. For simplicity, we use the application_onstart event.
The imported data must be at the beginning of the program or the first time the program enters the data. To simplify the process, the application_onstart event is used as follows:
Function application_onstart (){
// Initial data load.
VaR usersdata = new usersdataxml;
Usersdata. initialize ();
}

Data storage:
Data storage should occur when each change occurs. This is called only when the user registers. If the data changes frequently, we use an automatic access function. The Save operation is in the same function, but it is difficult to control the time period. This means that there is not enough time to write data during storage operations. To consider this possibility, you should use the userdata_autosave () method. Here, I need a final call to save the data before the program ends. In ASP, the program is application_onend ().
Note that the physical memory required for xml dom is 10 times the size of itself.
Other important aspects are to provide valid file paths and whether to allow read/write operations. If a file does not exist, it will be created after the first user registration, through the registeruser () method.
A registered chat room contains folders that can be read and written. It may be a DB folder, which is not a sub-folder of the network program. For example, <your local path>/samples/registrablechat/DB /.
Conclusion:
Are you still searching for more special programs? The next part describes how to create a chat room with many rooms.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.