⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.asc

📁 flash视频聊天源代码,采用fms和flash8开发
💻 ASC
字号:
load("components.asc")
application.onAppStart = function(){
	//Array of connected users
	this.userList = new Array();
	//Object to hold a direct reference to connected clients
	this.userHandler = new Object();
	//Shared Object to store connected users
	this.users_so = SharedObject.get("users", false);
	this.users_so.setProperty("userList", this.userList);	
}
application.onConnect = function(client, name) {
	//Check if the user exists
	for(i=0; i<this.userList.length; i++){		
		if(this.userList[i]==name){
			application.rejectConnection(client);
			return;
		}
	}	
	//register user to framework
	gFrameworkFC.getClientGlobals(client).username = name;
	// Store a reference to this user
	this.userHandler[name] = client;
	// Add this user to the userList array
	this.userList.push(name);
	//saves array of connected users to the Shared Object
	this.users_so.setProperty("users", this.userList);
	// Accept the new client's connection
 	this.acceptConnection(client, name);	
}
application.onConnectAccept = function(client, name){
 	//Sets username in client side
	client.call("setUser", null, name);
	//Broadcast the event to all connected users
	this.users_so.send("newUser", name);
}
application.onDisconnect = function(oldClient){
	//Get username from framework
	var username = gFrameworkFC.getClientGlobals(oldClient).username
	//Broadcast disconnection
	this.users_so.send("onDisconnect", username, true);
	//Deletes user reference
	delete this.userHandler[username]	
	//Deletes user from the users array and the SO
	for(i=0; i<this.userList.length; i++) {
		if(this.userList[i] == username) {
			this.userList.splice(i, 1)
			this.users_so.setProperty("userList", this.userList);
		}
	}
}

//Returns number of connected users 
Client.prototype.checkClients = function(){
	return application.userList.length
}
//Route an invitation from source to guest
Client.prototype.invite= function(source, guest){
	application.userHandler[guest].call("showMessage", null, source)
}
//Route an answer to an invitation with three posible states: true, false or "busy"
Client.prototype.joinRoom = function(source, guest, flag){
		application.userHandler[source].call("openRoom", null, flag, guest+"_"+source, guest)
		application.userHandler[guest].call("openRoom", null, flag, guest+"_"+source, source)
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -