fms视频会议系统服务端asc文件

application.onAppStart=function(){    
 
	application.ShareObject_ChatRoomMember = SharedObject.get("ShareObject_ChatRoomMember", false); 
	application.ShareObject_Boardcast = SharedObject.get("ShareObject_Boardcast", false); 
	application.ShareObject_PutupHand = SharedObject.get("ShareObject_PutupHand", false); 
	application.ShareObject_ChatRoomMessage = SharedObject.get("ShareObject_ChatRoomMessage", false); 



	
	application.ShareObject_ChatRoomVideo = SharedObject.get("ShareObject_ChatRoomVideo", false); 
	application.ShareObject_Attribute_OnLineUserList = SharedObject.get("OnLineUserList", false); 
	application.ShareObject_NetStream = SharedObject.get("ShareObject_NetStream", false); 

	application.boardcastList = new Array();
	application.onLineUserList = new Array();
	application.rejectUserList = new Array();
	application.putupHandList = new Array();
	application.sharedBoardData = new Array();
	application.sharedBoardDataList = new Array();
	application.userStreamPublisher = new Array();
}  


application.onConnect=function(client,userInfo, Maximum){    
	

	var len = application.onLineUserList.length;

	if(len > Maximum)
	{
		this.rejectConnection(client);
		return;
	}

	

	for(var i=0; i < application.rejectUserList.length; i++)
	{
		if(application.rejectUserList[i] == userInfo.Member_User.UserID)
		{
			
			this.rejectConnection(client);
			return;
		}
	}
	
	
	if(len > 0)
	{

		for(var i=0; i < len; i++)
		{
			if(application.onLineUserList[i].Member_User.UserID == userInfo.Member_User.UserID)
			{
				this.rejectConnection(client);
				return;
			}
		}
	}
	
	this.acceptConnection(client);
	client.userInfo = userInfo;
	application.onLineUserList.push(userInfo);    

	sendUserList();  
	


	var len = application.sharedBoardDataList.length;
	
	//将画板轨迹加入轨迹列表中
	client.AddTrackToSharedBoardData = function(track)
	{
		application.sharedBoardData.push(track);
	}

	//获取画板轨迹列表
	client.GetTrackData = function()
	{
		client.call("FmsCallbackHandler", null,"callBackGetTrackData", application.sharedBoardData);
	}

	//获取媒体流列表
	client.GetStreamData = function()
	{
		client.call("FmsCallbackHandler", null,"callBackGetStreamData", application.userStreamPublisher);
	}

	//清空画板
	client.ClearSharedBoardData = function()
	{
		application.sharedBoardData = new Array();
	}



	// 发布消息
	client.MessageFromClient = function(chat){
		chat.CreateDatetime = new Date();
		chat.FromIP = client.ip;
		chat.FromPC = application.hostname;
//		client.call("FmsCallbackHandler", null,"callBackSendMessage", chat);

		application.ShareObject_ChatRoomMessage.setProperty("ShareObject_ChatRoomMessage", chat);
	}

	


	//拒绝用户登录
	client.RejectUser = function(RejectUserID){
		//application.rejectUserList.push(RejectUserID);
		RejectUserHandler(RejectUserID);
	
	}

	//发送发布媒体流请求
	client.AskUserPublishStream = function(client,userInfo){
		callClientToPublishVideoStream(client,userInfo);
	}
	


	

	//发布公告
	client.PublishBoardcast = function(boardcastContent)
	{	
		application.boardcastList.push(boardcastContent);
		application.ShareObject_Boardcast.setProperty("ShareObject_Boardcast", boardcastContent);
	}

	
	//举手
	client.PutupHand = function(UserID)
	{
		
		for(var i=0;i<application.putupHandList.length;i++)
		{
			if(application.putupHandList[i] == UserID)
			{
				return;
			}
		}
		application.putupHandList.push(UserID);
		application.ShareObject_PutupHand.setProperty("ShareObject_PutupHand", application.putupHandList);
	}

	//删除举手
	client.RemovePutupHand = function(UserID)
	{	
		for(var i=0;i<application.putupHandList.length;i++)
		{
			if(application.putupHandList[i] == UserID)
			{
				application.putupHandList.splice(i,1);
				break;
			}
		}
		
		application.ShareObject_PutupHand.setProperty("ShareObject_PutupHand", application.putupHandList);
	}


	//发布用户媒体流
	client.PublishRemoteUserVideo = function(remoteUser){
		application.userStreamPublisher.push(remoteUser);
		ClientPublishVideoStream(remoteUser);
	}


	//关闭媒体流
	client.CloseMediaStream = function(remoteUser){
		RemoveStream(remoteUser);
	}

	//发送发布媒体流请求
	client.SendPublishRemoteUserVideoRequest = function(operationer, remoteUser){
		requestClientToPublishVideoStream(operationer, remoteUser);
	}

	client.RejectPublishMediaStream = function(operationer, remoteUser){
		SentRejectInfoToOperationer(operationer, remoteUser);
	}
}    


application.onDisconnect=function(client){  

	removeLeftUser(client.userInfo);  
	if(client.userInfo != null)
		RemoveStream(client.userInfo.Member_User.UserID);  
	sendUserList();   
	

	if(application.clients.length <= 0)
	{
		application.sharedBoardData = new Array();
	}
	
}  


function sendUserList(){
	application.ShareObject_ChatRoomMember.setProperty("ShareObject_ChatRoomMember", application.onLineUserList);
}




function RejectUserHandler(RejectUserID){
	var leng=application.clients.length;    
	for(var i=0;i<leng;i++){    
		if(application.onLineUserList[i].Member_User.UserID == RejectUserID){
			application.disconnect(application.clients[i]);
			break;
		}
    } 
	
}

function requestClientToPublishVideoStream(operationer, remoteUser){
	var leng=application.clients.length;    	

	for(var i=0;i<leng;i++){   
		if(application.clients[i].userInfo.Member_User.UserID == remoteUser.UserID){
			application.clients[i].call("FmsCallbackHandler", null,"callbackRequestToPublishMediaStream", operationer, remoteUser.streamType); 
			break;
		}
	}
}



function ClientPublishVideoStream(remoteUser){

	var leng=application.clients.length;    
	for(var i=0;i<leng;i++){    
		application.clients[i].call("FmsCallbackHandler", null,"ReceiveStream", remoteUser); 
	}
}



function SentRejectInfoToOperationer(operationer, remoteUser){
	var leng=application.clients.length;    
	for(var i=0;i<leng;i++){    
		if(application.clients[i].userInfo.Member_User.UserID == operationer){
			application.clients[i].call("FmsCallbackHandler",null,"callbackReceiveRejectInfo", remoteUser); 
			break;
		}
	}
}


function removeLeftUser(userInfo){
	for(var i=0;i<application.onLineUserList.length;i++){
		if(application.onLineUserList[i] == userInfo){
			application.onLineUserList.splice(i,1);
			break;
		}
	}
}


function RemoveStream(UserID)
{	
	for(var i=0; i < application.userStreamPublisher.length; i++)
	{
		if(application.userStreamPublisher[i].UserID == UserID)
		{
			for(var j=0;j<application.clients.length;j++){	
				application.clients[j].call("FmsCallbackHandler", null,"RemoveStream", UserID,application.userStreamPublisher[i].streamType); 
			}

			application.userStreamPublisher.splice(i,1);
			break;
		}
	}

}



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值