Click here to Skip to main content
11,798,866 members (74,145 online)
Click here to Skip to main content
Add your own
alternative version

Writing ASP Chat using JavaScript and XML (Part 4)

, 21 Jan 2004 82.1K 1.7K 32
The last part of the ASP chat series. This article explains how to provide a chat with multiple rooms.
function UsersDataXML() {
	this.authenticateUser = UsersDataXML_authenticateUser; = UsersDataXML_save;
	this.initialize = UsersDataXML_initialize;
	this.autoSave = UsersDataXML_autoSave;
	this.registerUser = UsersDataXML_registerUser;
	this.findUser = UsersDataXML_findUser;
	this.filePath = getUsersDataPath();
	this.autoSaveInterval = getAutoSaveInterval();// In seconds.
	this.identifier = "UsersStore";

 *  Cheks user name and password combination.
 *  @return true if valid user, overvise false.
function UsersDataXML_authenticateUser(userName, password) {
	var usersStore = new SharedXML(this.identifier);
	var xmlNode = usersStore.findNodeByName(userName);
	if(xmlNode != null) {
		var user = new UserInfo(xmlNode);
		return user.checkPassword(password);
	return false;

 *  Searching for an existing user by nick. 
 *  @param strNick user nick.
 *  @return Found user object or undefined, if not exists.
function UsersDataXML_findUser(strNick) {
	var usersStore = new SharedXML(this.identifier);
	var xmlNode = usersStore.findNodeByName(strNick);
	if(xmlNode != null)
		var user = new UserInfo(xmlNode);
		return user;

 *  Saves data to disk.
function UsersDataXML_save() {
	var usersStore = new SharedXML(this.identifier);;

 *  Initial data load.
function UsersDataXML_initialize() {
	var usersStore = new SharedXML(this.identifier);

 *  Checking for autosave timeout elapsed. If true, saves data.
function UsersDataXML_autoSave() {;

 *  Adds new user to store.
 *  @return New user id or -1 if already exists.
function UsersDataXML_registerUser(nick, password, firstName, 
								   lastName, email) {
	var user = this.findUser(nick);
	if(typeof(user) != "undefined") {
		// User already exists.
		return -1;
	var usersStore = new SharedXML(this.identifier);
	var xmlNode = usersStore.addNode();
	var newUser = new UserInfo(xmlNode);

	var id = newUser.getUserID();
	return id;

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Alexander Fedorenko
Web Developer
Ukraine Ukraine
Alexander Fedorenko is a professional C++ developer since 1996. He completed many custom and shareware projects. One of the successful projects is DevPlanner - tool for personal planning and time management.

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.151002.1 | Last Updated 22 Jan 2004
Article Copyright 2004 by Alexander Fedorenko
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid