You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bluesky-commits@incubator.apache.org by ma...@apache.org on 2010/09/27 12:20:50 UTC

svn commit: r1001701 [2/4] - in /incubator/bluesky/branches/apache-bluesky-realclass0.2.0: ./ TserverQT-0.2.0/

Added: incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/adminserver.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/adminserver.cpp?rev=1001701&view=auto
==============================================================================
--- incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/adminserver.cpp (added)
+++ incubator/bluesky/branches/apache-bluesky-realclass0.2.0/TserverQT-0.2.0/adminserver.cpp Mon Sep 27 12:20:49 2010
@@ -0,0 +1,5490 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements.  See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership.  The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License.  You may obtain a copy of the License at
+//
+//  http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied.  See the License for the
+//specific language governing permissions and limitations
+//under the License. 
+
+// AdminServer.cpp: implementation of the CAdminServer class.
+//////////////////////////////////////////////////////////////////////
+#include "stdafx.h"
+#include "adminserver.h"
+#include <linux/msg.h>
+#include <fcntl.h>
+
+
+#include "languagechoose.h"  //language change    2007.11.10
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+//extern GtkWidget *textview_info;
+//extern GtkTextBuffer *buffer;
+//extern GtkTextIter end;
+//extern GtkWidget *clist_room;
+//extern GtkWidget *clist_teacher;
+//extern GtkWidget *clist_student;
+//extern GtkWidget *clist_mcu;
+//extern GtkWidget *clist_semcu;
+
+#define PACKET_SIZE 4096  
+#define MAX_WAIT_TIME 5  
+#define MAX_NO_PACKETS 3 
+#define TEXTBUFFERLEN 500
+
+char sendpacket[PACKET_SIZE];  
+char recvpacket[PACKET_SIZE];  
+int sockfd,datalen=56;  
+int nsend,nreceived;  
+struct sockaddr_in dest_addr;  
+pid_t pid;  
+struct sockaddr_in from;  
+struct timeval tvrecv; 
+
+void  SendThreadProc( void* args );
+void  ScanTimerProc(int hwnd, UINT uMSG, UINT idEvent, DWORD dwTime);
+
+void  SendThreadProc( void* pv )
+{
+	//event
+	
+	if(pv == NULL)
+	{
+		
+		return;
+	}
+	CAdminServer *pAdminServer = (CAdminServer*)pv;
+	CRCLSendMSG *pRM = NULL;
+    msgbuf msg1;
+
+}
+
+CAdminServer *pAdminServer = NULL;
+
+CAdminServer::CAdminServer()
+{
+	rclSendThreadHandle = 0;
+	rclSendThreadID = 0;
+
+	umu.Init();
+	tmu.Init();
+	mmu.Init();
+	smu.Init();
+	rmu.Init();
+	imu.Init();
+        dmu.Init();
+	Jtext_layoutC.Init();
+	Jtext_layoutT.Init();
+
+	rclSysMax = 1000;
+	rclGroupMax = 100;
+	rclMCUChoose = 0;
+
+	//rander = time(0);
+	//hScan = SetTimer(NULL, 1, 5000, ScanTimerProc);
+	pAdminServer = this;
+
+}
+
+
+void ScanTimerProc(int hwnd, UINT uMsg, UINT idEvent, DWORD dwTime)
+{
+	pAdminServer->rclScanSys();
+}
+
+CAdminServer::~CAdminServer()
+{
+	//return ;
+	umu.Lock();
+	if(UserList.size())
+	{
+		rclUserList::iterator it;
+	    for(it = UserList.begin();it != UserList.end();++it)
+	    {
+		     delete *it;
+		     *it = NULL;
+	     }
+	    UserList.clear();
+     }
+	 umu.Unlock();
+
+	tmu.Lock();
+    if(TeacherList.size())
+    {
+	    rclTeacherList::iterator it;
+	    for(it = TeacherList.begin();it != TeacherList.end();++it)
+	    {
+		    delete *it;
+		    *it =NULL;
+	    }
+	    TeacherList.clear();
+    }
+    tmu.Unlock();
+
+    mmu.Lock();
+    if(MCUList.size())
+    {
+	    rclMCUList::iterator it;
+	    for(it = MCUList.begin();it != MCUList.end();++it)
+	    {
+		    delete *it;
+		    *it =NULL;
+	    }
+	    MCUList.clear();
+    }
+    mmu.Unlock();
+
+    smu.Lock();
+    if(SeMCUList.size())
+    {
+	    rclSeMCUList::iterator it;
+	    for(it = SeMCUList.begin();it != SeMCUList.end();++it)
+	    {
+		    delete *it;
+		    *it =NULL;
+	    }
+	    SeMCUList.clear();
+    }
+    smu.Unlock();
+
+    rmu.Lock();
+    if(RoomList.size())
+    {
+	    rclRoomList::iterator it;
+	    for(it = RoomList.begin();it != RoomList.end();++it)
+	    {
+		    (*it)->rclUserRoom.clear();
+		    (*it)->rclSeMCURoom.clear();
+		    delete *it;
+		    *it =NULL;
+	    }
+	    RoomList.clear();
+    }
+    rmu.Unlock();
+
+    imu.Lock();
+    if(IPList.size())
+    {
+	    IPList.clear();
+    }
+    imu.Unlock();
+
+    dmu.Lock();
+    if(IDList.size())
+    {
+	    IDList.clear();
+    }
+    dmu.Unlock();
+
+    
+}
+
+
+void CAdminServer::rclScanSys()
+{
+	//if(bRun)
+	//{
+	    
+		CAsyncSocketEx asy;
+		rclIPList::iterator itp;
+		imu.Lock();
+		for(itp = IPList.begin();itp != IPList.end(); ++itp)
+		{
+			char bb[10] = "abcdefghi";
+            asy.Attach((*itp)->s, 0);
+            asy.Send(&bb, 10, 0);
+			asy.Detach( );
+		}
+		imu.Unlock();
+	//}
+}
+
+int CAdminServer::Init()
+{
+//	//	gtk_text_buffer_insert(buffer,&end,pInit,-1);
+
+//	bRun = TRUE;
+        bRun = 1;
+	ClientTalk = 1;
+	//NodeInfoOut = pNcn;
+	rclSysMax = 1000;
+	rclTeacherMax = 10;
+	rclStudentMax = 1000;
+	ListenPort = 8000;
+	MaxOnline = 1000;
+	MaxTeacherOnline = 10;
+	MaxStudentOnline = 1000;
+	
+    rclCurrentNum = 0;
+    sum = 0;
+    count = 1;	
+	InitializeIDList(rclSysMax);
+
+	
+	m_listemsocket.m_pServer = this;
+	if(!m_listemsocket.Create(12345)){
+		printf("create failed!\n");
+		bool re = true;
+		int one = 1;
+		if(!m_listemsocket.SetSockOpt(SO_REUSEADDR, (char *) &one, sizeof(int), SOL_SOCKET))
+			printf("set failed!!\n");
+
+	}
+	if(!m_listemsocket.Listen()){
+		int d;
+
+		printf("\nListen faild:\n");
+		return false;
+	}
+	m_listen.Init()	;
+	m_listen.Start();
+
+	
+//	gtk_text_buffer_insert(buffer,&end,pstarted,-1);
+	m_listen.Attach(&m_listemsocket);
+	int i;
+	for(i=0; i<THREADCOUNT; i++){
+		m_accept[i].Init();
+		m_accept[i].Start();
+	}
+	return true;
+}
+
+int CAdminServer::InitializeIDList(DWORD IDCount)
+{
+	if((IDCount + 1) >= (0xFFFFFFFF - 2))
+		return 0;
+	dmu.Lock();
+	for(int i = 0;i<IDCount;i++)
+		IDList.push_back(i+1);
+	dmu.Unlock();
+	return 1;
+}
+
+BOOL CAdminServer::ParseRequest(CRCLMSG* pM, int event, SOCKET s, BOOL &bKeepAlive)
+{
+	int i;
+	
+	
+
+
+	bKeepAlive = true;
+	printf("%d\n",pM->rclType);
+	printf("%d\n",pM->msglen);
+
+	if(pM->rclType >= 10000)
+	{
+		
+		switch (pM->rclType)
+		{
+			case 10000:
+				
+				rclTeacherCreateGroup((CRCLCreateGroup*)&pM->msg,s);
+				break;
+			case 10010:
+				
+				rclTeacherLeaveGroup((CRCLDestroyGroup*)&pM->msg,s);
+				break;
+			case 10020:
+				
+				rclClientJoinGroup((CRCLClientJoinInGroup*)&pM->msg,s);
+				break;
+			case 10030:
+				
+				rclClientLeaveGroup((CRCLClientLeaveGroup*)&pM->msg,s);
+				break;
+				
+			case 10040:
+				rclMCULeaveGroup((CRCLMCULeaveGroup*)&pM->msg,s);
+				break;
+				
+			case 10050:
+				rclClientGetGroupInfo((CRCLClientGetCroupInfo*)&pM->msg,s);
+				break;
+				
+			case 10060:
+				rclSeMCUGetGroupInfo((CRCLSeMCUGetGroupInfo*)&pM->msg,s);
+				break;
+				
+			case 10070:
+				rclSeMCUJoinGroup((CRCLSeMCUJoinGroup*)&pM->msg,s);
+				break;
+				
+			case 10080:
+				rclSeMCULeaveGroup((CRCLSeMCULeaveGroup*)&pM->msg,s);
+				break;
+			default:
+				return false;
+		}
+		return true;
+	}
+	
+
+	
+	if(pM->rclType >= 5000)
+	{
+		
+		switch(pM->rclType) 
+		{
+		case 5000:
+			
+			rclTeacherLogin((CRCLTeacherLogin*)&pM->msg,s,event);//pass 4.26
+			break;
+		case 5010:
+			
+			rclMCULogin((CRCLMCULogin*)&pM->msg,s,event);//pass 4.26
+			break;
+		case 5020:
+			
+			rclClientLogin((CRCLClientLogin*)&pM->msg,s,event);//pass 4.27
+ 			break;
+		case 5030:
+			
+			rclTeacherLogout((CRCLTeacherLogout*)&pM->msg,s);//4.27
+			break;
+		case 5040:
+			
+			rclMCULogout((CRCLMCULogout*)&pM->msg,s);//4.27
+			break;
+		case 5050:
+			
+			rclClientLogout((CRCLClientLogout*)&pM->msg,s);//4.27
+			break;
+		case 5060:
+			
+			rclSeMCULogin((CRLCSeMCULogin*)&pM->msg,s,event);//4.27
+			break;
+		case 5070:
+			
+			rclSeMCULogout((CRCLSeMCULogout*)&pM->msg,s);
+			break;
+		default:
+			return false;
+		}
+		return true;
+	}
+
+	
+	if(pM->rclType >= 1000)
+	{
+		
+		switch(pM->rclType) 
+		{
+		case 1000:
+			
+			rclTeacherTextBroadcast((CRCLTeacherTextBroadcast*)&pM->msg,s);
+			break;
+		case 1010:
+			
+			rclClientApplyFocus((CRCLClientApplyFocus*)&pM->msg,s);
+			break;
+		case 1020:
+			
+			rclClientDestroyFocus((CRCLClientDestroyFocus*)&pM->msg,s);
+			break;
+		case 1030:
+			
+			rclClientTextBroadcast((CRCLClientTextBroadcast*)&pM->msg,s);
+			break;
+		case 1040:
+			
+			rclClientGetClientInfo((CRCLClientGetClientInfo*)&pM->msg,s);
+			break;
+		case 1050:
+			
+			rclTeacherAllowClientFocus((CRCLTeacherAllowClientFocus*)&pM->msg,s);
+			break;
+		case 1060:
+			
+			rclTeacherCancelClientFocus((CRCLTeacherCancelClientFocus*)&pM->msg,s);
+			break;
+		case 1070:
+			
+			rclTeacherGetClientList((CRCLTeacherGetClientList*)&pM->msg,s);
+			break;
+		case 1080:
+			
+			rclTeacherSwitchMode((CRCLTeacherSwitchMode*)&pM->msg,s);
+			break;
+		case 1090:
+			rclTeacherChat((CRCLTeacherChat *)&pM->msg ,s);
+			break;
+			
+		default:
+			return false;
+		}
+	}
+
+	return true;
+}
+int CAdminServer::rclSendMessage(DWORD userid, std::string msg)
+{
+	
+
+	//search user's socket
+	
+	rclUserList::iterator it;
+		
+	for(it = UserList.begin();it != UserList.end(); ++it)
+	{
+		if((*it)->rclClientID == userid)
+		{
+			SOCKET s = (*it)->s;
+
+	       
+	        CRCLSendMSG *pRCSM = new CRCLSendMSG;
+
+	        pRCSM->msg = msg;
+	        pRCSM->s = s;
+
+	        if(!rclSendThreadID)
+	        {
+		        return 1;
+	        }
+			
+			//06.03.31
+	        return 0;
+		}
+	}	
+	if(it == UserList.end())
+	{
+		return 1;
+	}
+}
+
+int CAdminServer::rclSendM()
+{
+	return 1;
+}
+
+int CAdminServer::GotConnection(SOCKET s, char* ip, int port)
+{
+	CRCLNodeIP* Node = new CRCLNodeIP;
+	Node->s = s;
+	memcpy(Node->IP,ip,16);
+	rclIPList::iterator itp;
+	imu.Lock();
+	for(itp = IPList.begin();itp != IPList.end();++itp)
+	{
+		if((*itp)->s == s)
+		{
+			imu.Unlock();
+			printf("same socket\n");
+			return 1;
+		}
+	}
+	IPList.push_back(Node);
+	imu.Unlock();
+	rclCurrentNum++;
+	return 1;
+}
+
+int CAdminServer::Disconnect(SOCKET s)
+{
+	
+	rclIPList::iterator itp;
+    printf("enter ip lock\n");	
+	imu.Lock();
+	printf("entered ip lock\n");
+	for(itp = IPList.begin();itp != IPList.end(); ++itp)
+	{
+		if((*itp)->s == s)
+		{
+	        if(itp != IPList.end())
+	        {
+				delete (*itp);
+				(*itp) = NULL;
+		        IPList.erase(itp);
+				rclCurrentNum--;
+	        }
+			break;
+		}		
+	}	
+	imu.Unlock();
+
+	
+	rclUserList::iterator itu;
+	printf("enter user lock\n");
+	umu.Lock();
+	printf("entered user lock\n");
+    for(itu = UserList.begin();itu != UserList.end(); ++itu)
+	{
+		if((*itu)->s == s)
+		{
+	        if(itu != UserList.end())
+	        {
+		       
+		        CRCLClientLogout Msg;
+		        Msg.ClientID = (*itu)->rclClientID;
+
+		       
+		        
+		        umu.Unlock();
+				printf("out user lock\n");
+		        rclClientLogout(&Msg,s);
+		
+		        return 0;
+	        }
+		}
+	}
+	umu.Unlock();
+
+	
+	rclTeacherList::iterator itt;
+	printf("enter teacher lock\n");
+	tmu.Lock();
+	printf("entered teacher lock\n");
+    for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+	{
+		if((*itt)->s == s)
+		{
+	        if(itt != TeacherList.end())
+	        {
+		     
+		        CRCLTeacherLogout Msg;
+		        Msg.TeacherID = (*itt)->rclTeacherID;
+		
+		        tmu.Unlock();
+		        rclTeacherLogout(&Msg,s);
+		
+		        return 0;
+	        }
+		}
+	}
+	tmu.Unlock();
+
+	
+	rclMCUList::iterator itm;
+	printf("enter mcu lock\n");
+	mmu.Lock();
+	printf("entered mcu lock\n");
+    for(itm = MCUList.begin();itm != MCUList.end();++itm)
+	{
+        if((*itm)->s == s)
+        {			
+	        if(itm != MCUList.end())
+	        {
+		      
+		        CRCLMCULogout Msg;
+		        Msg.MCUID = (*itm)->rclMCUID;
+		
+		        mmu.Unlock();
+		        rclMCULogout(&Msg,s);
+
+		        return 0;
+	        }
+		}
+	}
+	mmu.Unlock();
+
+
+	rclSeMCUList::iterator its;
+	printf("enter semcu lock\n");
+	smu.Lock();
+	printf("entered semcu lock\n");
+	for(its = SeMCUList.begin();its != SeMCUList.end();++its)
+	{
+		if((*its)->s == s)
+		{
+	        if(its != SeMCUList.end())
+	        {
+		     
+		        CRCLSeMCULogout Msg;
+		        Msg.MCUID = (*its)->rclMCUID;
+
+		        smu.Unlock();
+		        rclSeMCULogout(&Msg,s);
+
+		        return 0;
+	        }
+		}
+	}
+	smu.Unlock();
+
+	return 1;
+}
+
+int CAdminServer::rclBroadCast(DWORD)
+{
+	rclUserList::iterator it;
+	for(it = UserList.begin();it != UserList.end();++it)
+	{
+		rclSendMessage((*it)->rclClientID,"hello");
+	}
+	return 1;
+}
+
+int CAdminServer::DataSent(DWORD)
+{
+	
+}
+
+BOOL CAdminServer::IsComplete(std::string)
+{
+	return 1;
+}
+
+int CAdminServer::rclUserSendTextToUser()
+{
+}
+
+int CAdminServer::rclUserSendTextToGroup(DWORD userid, DWORD groupid, std::string text, int flag)
+{
+	char textbuf[TEXTBUFFERLEN];
+	rclUserList::iterator itu;
+	umu.Lock();
+	for(itu = UserList.begin();itu != UserList.end();++itu)
+	{
+		if((*itu)->rclClientID == userid)
+		{
+			sprintf(textbuf,pstu_sed_text,(*itu)->rclName); 
+		}
+	}
+	umu.Unlock();
+	
+
+	rclRoomList::iterator it;
+	CAsyncSocketEx asy;
+	rmu.Lock();
+	
+	for(it = RoomList.begin();it != RoomList.end();++it)
+	{
+		if((*it)->rclRoomID == groupid)
+		{
+			rmu.Unlock();
+			
+			
+//			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//			//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+	        std::list<DWORD>::iterator ita;
+			(*it)->cs.Lock();
+	        for(ita=(*it)->rclUserRoom.begin();ita!=(*it)->rclUserRoom.end();++ita)
+	        {
+		        if(ita == (*it)->rclUserRoom.end())
+		        {
+			        break;
+		        }
+		        if((*ita == userid) && flag)
+		        {
+			      
+			        break;
+		        }
+		        
+		        rclUserList::iterator itb;
+				umu.Lock();
+		        for(itb = UserList.begin();itb != UserList.end();++itb)
+				{
+					if((*itb)->rclClientID == *ita)
+					{
+						
+		                SOCKET s = (*itb)->s;
+						umu.Unlock();
+		              
+		                char *wBuffer;
+		                wBuffer = (char*)malloc(text.size());
+		                memcpy(wBuffer,text.c_str(),text.size());
+		                asy.Attach(s,0);
+		                asy.Send(wBuffer,text.size(),0);
+						asy.Detach();
+						break;
+					}
+				}
+				if(itb == UserList.end())
+		        {
+					umu.Unlock();
+			       
+			        break;
+		        }		        		
+	        }
+            (*it)->cs.Unlock();
+	        return 0;
+		}
+	}
+	if(it == RoomList.end())
+	{
+		rmu.Unlock();
+		return 1;
+	}
+}
+
+int CAdminServer::rclTeacherLogin(CRCLTeacherLogin *pMSG,SOCKET s, int event)
+{
+	char textbuf[TEXTBUFFERLEN];
+	sprintf(textbuf,pteacher_login,pMSG->TeacherName);  //"%",pMSG->TeacherName);
+	printf("%s\n",pMSG->TeacherName);
+	if ((TeacherList.size() +1 ) <= rclTeacherMax) 
+	{
+    
+	    
+	    tmu.Lock();
+	    rclTeacherList::iterator it_online;
+	    for(it_online = TeacherList.begin();it_online != TeacherList.end();++it_online)
+		{
+
+			if(!strcmp((*it_online)->rclName, pMSG->TeacherName))
+			{
+				printf("here in\n");
+	            if(it_online != TeacherList.end())
+	            {
+		          
+		            if(strncmp((*it_online)->rclPass,pMSG->TeacherPass,16) == 0)
+		            {
+
+//						gtk_text_buffer_insert(buffer,&end,perror001,-1);
+						tmu.Unlock();
+			          
+			            
+			            
+
+						rclResponseError(5001,s,RCL_USER_AlREADY_ONLINE);
+						return 1;
+		            }
+		            else
+		            {
+			           
+
+
+//						gtk_text_buffer_insert(buffer,&end,perror002,-1);
+			            tmu.Unlock();
+			            rclResponseError(5001,s,RCL_USER_AlREADY_ONLINE);
+			            return 1;
+		            }
+	            }
+			}
+		}
+	    tmu.Unlock();
+
+	
+	
+	    CRCLTeacher *pNode = new CRCLTeacher;
+	    memcpy(pNode->rclName,pMSG->TeacherName,NAMELEN);//06.10.11
+	    memcpy(pNode->rclPass,pMSG->TeacherPass,16);
+	    pNode->s = s;
+	    memset(pNode->rclIP,0,16);
+		
+	    rclIPList::iterator itp;
+	    imu.Lock();
+	    for(itp = IPList.begin();itp != IPList.end();++itp)
+		{
+			if((*itp)->s == s)
+			{
+				
+
+				memcpy(pNode->rclIP,(*itp)->IP,16);
+
+	            imu.Unlock();
+	
+	            memcpy(pNode->rclLocalIP,pMSG->TeacherIP,16);
+
+				
+	            pNode->rclPort = 0;
+	            pNode->rclSAPort = 0;
+	            pNode->rclSVPort = 0;
+	            pNode->rclRoomID = 0;
+	            pNode->rclTeacherID = rclPopPushID(0);
+	            pNode->ThreadEvent = event;
+	            if(pNode->rclTeacherID == 0)
+	            {
+		            rclResponseError(5001,s,RCL_MAX_USER);
+		            delete pNode;
+		            pNode = NULL;
+		            return 1;
+	            }
+	
+	            
+	            tmu.Lock();
+	            TeacherList.push_back(pNode);
+	            tmu.Unlock();
+	
+
+	
+	           
+	            CRCLMSG response;
+	            CRCLTeacherLoginR res;
+	
+	            res.ResponseType = 0;
+	            res.TeacherID = pNode->rclTeacherID;
+	
+	           
+	            DWORD ClassCount = 0;
+	            memset(res.ClassInfo,0,sizeof(res.ClassInfo));
+	            res.ClassInfoReturn = 1;
+	            res.ClassInfoCount = 1;
+	
+	            response.msglen = sizeof(CRCLTeacherLoginR) - 15*sizeof(CRCLUserClassInfo);
+	            response.rclType = 5001;
+
+				rclMakePacket(response.msg,(char*)&res,response.msglen);
+
+                                //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//				//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+
+	            
+	            return rclSendResponse((char*)&response,response.msglen+8,&s,1);
+				
+			}
+		}
+		if(itp == IPList.end())
+	    {
+		  
+		    imu.Unlock();
+		    rclResponseError(5001,s,RCL_LOGIN_ERROR);
+		    delete pNode;
+		    pNode = NULL;
+		    return 1;
+	    }
+    }
+    else
+    {
+	    rclResponseError(5001,s,RCL_MAX_TEACHER);
+	    return 1;    
+    }
+}
+
+
+int CAdminServer::rclTeacherLogout(CRCLTeacherLogout *pMSG, SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+	
+	rclTeacherList::iterator itt;
+	tmu.Lock();
+	for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+	{
+		if((*itt)->rclTeacherID == pMSG->TeacherID)
+		{
+			sprintf(textbuf,pteacher_logout,(*itt)->rclName);  
+			printf("step1\n");
+			
+	        DWORD teacherid = (*itt)->rclTeacherID;
+	        DWORD roomid = (*itt)->rclRoomID;
+	        tmu.Unlock();
+	
+	    
+	        if(roomid)
+	        {
+		       
+				printf("step2\n");
+		        CRCLDestroyGroup msg;
+		        msg.GroupID = roomid;
+		        msg.TeacherID = teacherid;
+		     
+		        rclTeacherLeaveGroup(&msg,s);
+	        }
+	
+	      
+	        tmu.Lock();
+			rclTeacherList::iterator itt1;
+	        for(itt1 = TeacherList.begin();itt1 != TeacherList.end();++itt1)
+			{
+				printf("step9\n");
+				if((*itt1)->rclTeacherID == pMSG->TeacherID)
+				{
+					printf("step10\n");
+					rclPopPushID((*itt1)->rclTeacherID);
+	                delete (*itt1);
+	                (*itt1) = NULL;
+	                TeacherList.erase(itt1);
+	                tmu.Unlock();
+                                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//					//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+
+	
+	                return 0;
+				}
+			}
+			if(itt1 == TeacherList.end())
+	        {
+		        
+		        tmu.Unlock();
+		       
+		        return 1;
+	        }
+		}
+	}
+	if(itt == TeacherList.end())
+	{
+		
+		tmu.Unlock();
+		
+		return 1;
+	}
+}
+
+int CAdminServer::rclMCULogin(CRCLMCULogin *pMSG, SOCKET s,int event)
+{
+	char textbuf[TEXTBUFFERLEN];
+	sprintf(textbuf,prmcu_login,pMSG->MCUName);  
+	
+	mmu.Lock();
+	rclMCUList::iterator it_online;
+
+	for(it_online = MCUList.begin();it_online != MCUList.end();++it_online)
+	{
+		printf("%s\n",(*it_online)->rclName);
+		printf("%s\n",pMSG->MCUName);
+		if(!strcmp((*it_online)->rclName, pMSG->MCUName))
+		{			
+	        if(it_online != MCUList.end())
+	        {
+		        
+		        if(strncmp((*it_online)->rclPass,pMSG->MCUPass,16) == 0)
+		        {
+//			        gtk_text_buffer_insert(buffer,&end,perror003,-1);
+					mmu.Unlock();
+					return 1;
+		        }
+		        else
+		        {
+			      
+
+//					gtk_text_buffer_insert(buffer,&end,perror004,-1);
+			        mmu.Unlock();
+
+			        rclResponseError(5011,s,RCL_USER_AlREADY_ONLINE);
+			        return 1;
+		        }	
+	        }
+	    }
+    }
+	mmu.Unlock();
+	
+
+	CRCLMCU* pNode = new CRCLMCU;
+	memset(pNode->rclIP,0,16);
+	rclIPList::iterator itp;
+	imu.Lock();
+	for(itp = IPList.begin();itp != IPList.end();++itp)
+	{
+		if((*itp)->s == s)
+		{
+			memcpy(pNode->rclIP,(*itp)->IP,16);
+	        imu.Unlock();
+	
+			//06.03.31
+	        pNode->rclMCUID = rclPopPushID(0);
+	        if(pNode->rclMCUID == 0)
+	        {
+				//06.03.31
+		        rclResponseError(5011,s,RCL_MAX_USER);
+		        delete pNode;
+		        pNode = NULL;
+		        return 1;
+	        }
+	        memcpy(pNode->rclLocalIP,pMSG->MCUIP,16);
+	        pNode->rclSAPort = pMSG->CAPort;
+	        pNode->rclSVPort = pMSG->CVPort;
+	        pNode->rclTAPort = pMSG->TAPort;
+	        pNode->rclTSPort = pMSG->TSPort;
+	        pNode->rclTVPort = pMSG->TVPort;
+	        pNode->s = s;
+	        pNode->rclRoomID = 0;
+	        pNode->ThreadEvent = event;
+	        memcpy(pNode->rclPass,pMSG->MCUPass,16);
+	        memcpy(pNode->rclName,pMSG->MCUName,NAMELEN);//06.10.11
+	
+	      
+	        mmu.Lock();
+	        MCUList.push_back(pNode);
+	        mmu.Unlock();
+	
+	      
+	        CRCLMSG response;
+	        CRCLMCULoginR res;
+	        res.ResponseType = 0;
+	        res.MCUID = pNode->rclMCUID;
+	        response.msglen = sizeof(CRCLMCULoginR);
+	        response.rclType = 5011;
+
+
+			//06.03.31
+	        rclMakePacket(response.msg,(char*)&res,response.msglen);
+
+                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//			//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+	      
+	        rclSendResponse((char*)&response,response.msglen+8,&s,1);
+	        return 0;
+		}
+	}
+	if(itp == IPList.end())
+	{
+		imu.Unlock();
+		//06.03.31
+		rclResponseError(5011,s,RCL_LOGIN_ERROR);
+		delete pNode;
+		pNode = NULL;
+		return 1;
+	}	
+}
+
+
+int CAdminServer::rclMCULogout(CRCLMCULogout *pMSG, SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+
+	
+	rclMCUList::iterator itm;
+	mmu.Lock();
+
+	for(itm = MCUList.begin();itm != MCUList.end();++itm)
+	{
+		if((*itm)->rclMCUID == pMSG->MCUID)
+		{
+			sprintf(textbuf,prmcu_logout,(*itm)->rclName); 
+			
+			DWORD mcuid = (*itm)->rclMCUID;
+			DWORD roomid = (*itm)->rclRoomID;
+			mmu.Unlock();
+	
+	
+		
+			if(roomid)
+			{
+				
+				CRCLMCULeaveGroup msg;
+				msg.GroupID = roomid;
+				msg.MCUID = mcuid;
+				
+				rclMCULeaveGroup(&msg,s);
+			}
+	
+			
+			mmu.Lock();
+			rclMCUList::iterator itm1;
+
+			for(itm1 = MCUList.begin();itm1 != MCUList.end();++itm1)
+			{
+				if((*itm1)->rclMCUID == pMSG->MCUID)
+				{
+
+					//06.03.31
+			        rclPopPushID((*itm1)->rclMCUID);
+			        delete (*itm1);
+			        (*itm1) = NULL;
+			        MCUList.erase(itm1);
+			        mmu.Unlock();
+
+                                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//					//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+
+			       
+			        return 0;
+				}
+			}
+			if(itm1 == MCUList.end())	
+			{
+				
+				mmu.Unlock();
+			
+				return 1;
+			}			
+		}
+	}
+	if(itm == MCUList.end())	
+	{
+		
+		mmu.Unlock();
+		
+		return 1;
+	}
+}
+
+int CAdminServer::rclClientLogin(CRCLClientLogin *pMSG, SOCKET s, int event)
+{
+	char textbuf[TEXTBUFFERLEN];
+	sprintf(textbuf,pstu_login,pMSG->ClientName);  
+
+	if ((UserList.size()+1)<=rclStudentMax)
+	{
+	    
+	    umu.Lock();
+	    rclUserList::iterator it_online;
+
+	    for(it_online = UserList.begin();it_online != UserList.end();++it_online)
+		{
+			if(!strcmp((*it_online)->rclName, pMSG->ClientName))
+			{
+	            if(it_online != UserList.end())
+	            {
+		            
+		            if(strncmp((*it_online)->rclPass,pMSG->ClientPass,16) == 0)
+		            {
+			    
+			           
+			          
+//						gtk_text_buffer_insert(buffer,&end,perror005,-1);
+						umu.Unlock();
+						rclResponseError(5021,s,RCL_USER_AlREADY_ONLINE);
+						return 1;
+		            }
+		            else
+		            {
+			           
+						
+//						gtk_text_buffer_insert(buffer,&end,perror006,-1);
+			            umu.Unlock();
+						//06.04.03
+			            rclResponseError(5021,s,RCL_USER_AlREADY_ONLINE);
+			            return 1;
+		            }
+	            }
+			}
+		}
+	    umu.Unlock();
+	
+
+	    CRCLClient *pNode = new CRCLClient;
+	   
+	    pNode->rclClientID = rclPopPushID(0);
+	    if(pNode->rclClientID == 0)
+	    {
+			//06.04.03
+		    rclResponseError(5021,s,RCL_MAX_USER);
+		    delete pNode;
+		    pNode = NULL;
+		    return 1;
+	    }
+	    memset(pNode->rclIP,0,16);
+	    rclIPList::iterator itp;
+	    imu.Lock();
+	    for(itp = IPList.begin();itp != IPList.end();++itp)
+		{
+			if((*itp)->s == s)
+			{
+				
+                memcpy(pNode->rclIP,(*itp)->IP,16);
+	            imu.Unlock();
+	
+	            
+	            memcpy(pNode->rclLocalIP,pMSG->ClientIP,16);//"192.168.182.27",16);//pMSG->ClientIP,16);
+	            if (strcmp(pNode->rclIP,pNode->rclLocalIP) == 0) 
+	                pNode->rclClientType = 0; 
+	            else
+	                pNode->rclClientType = 1; 
+	  
+	         
+	            memcpy(pNode->rclName,pMSG->ClientName,NAMELEN);//06.10.11
+	            memcpy(pNode->rclPass,pMSG->ClientPass,16);
+	            pNode->rclRoomID = 0;
+	            pNode->rclMCUID = 0;
+	            pNode->rclSAPort = 0;
+	            pNode->rclSVPort = 0;
+	            pNode->rclTAPort = 0;
+	            pNode->rclTVPort = 0;
+	            pNode->rclTSPort = 0;
+				
+	       
+	            pNode->rclSeMCU_SAPort = pMSG->SeMCU_SAPort;
+	            pNode->rclSeMCU_SVPort = pMSG->SeMCU_SVPort;
+	            pNode->rclSeMCU_TAPort = pMSG->SeMCU_TAPort;
+	            pNode->rclSeMCU_TSPort = pMSG->SeMCU_TSPort;
+	            pNode->rclSeMCU_TVPort = pMSG->SeMCU_TVPort;
+
+	            pNode->rclIfSeMCU = 0;
+
+	            pNode->s = s;
+	         
+	            pNode->ThreadEvent = event;
+	
+	         
+	       
+	            umu.Lock();
+	            UserList.push_back(pNode);
+	            umu.Unlock();
+	
+            
+	            CRCLMSG response;
+	            CRCLClientLoginR res;
+	            res.ClientID = pNode->rclClientID;
+	            res.ClientType = pNode->rclClientType;
+	            res.ResponseType = 0;
+	
+	            
+	          
+	            response.rclType = 5021;
+	           
+	            response.msglen = sizeof(CRCLClientLoginR);
+				//06.04.03
+	            rclMakePacket(response.msg,(char*)&res,response.msglen);
+
+                                //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+                                //							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+
+	            
+	            return rclSendResponse((char*)&response,response.msglen+8,&s,1);
+			}
+		}
+		if(itp == IPList.end())
+	    {
+		    imu.Unlock();
+			//06.04.03
+		    rclResponseError(5021,s,RCL_LOGIN_ERROR);
+		    delete pNode;
+		    pNode = NULL;
+	 	    return 1;
+	    }	  
+	}
+	else
+	{
+		//06.04.03
+        rclResponseError(5021,s,RCL_MAX_STUDENT);
+	    return 1;
+	}	
+}
+
+int CAdminServer::rclClientLogout(CRCLClientLogout *pMSG, SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+	
+	
+	rclUserList::iterator it;
+	umu.Lock();
+	for(it = UserList.begin();it != UserList.end();++it)
+	{
+		if((*it)->rclClientID == pMSG->ClientID)
+		{
+			sprintf(textbuf,pstu_logout,(*it)->rclName);  
+			
+	        DWORD roomid = (*it)->rclRoomID;
+	        DWORD userid = (*it)->rclClientID;
+	
+	        umu.Unlock();	
+	
+	        if(roomid)
+	        {
+		      
+		        CRCLClientLeaveGroup msg;
+		        msg.ClientID = userid;
+		        msg.GroupID = roomid;
+		        
+		        rclClientLeaveGroup(&msg,s);
+	        }
+	
+	        umu.Lock();
+			rclUserList::iterator it1;
+	       
+
+	        for(it1 = UserList.begin();it1 != UserList.end();++it1)
+			{
+				if((*it1)->rclClientID == pMSG->ClientID)
+				{
+
+					//06.04.03
+	                rclPopPushID((*it1)->rclClientID);
+	                delete (*it1);
+	                (*it1) = NULL;
+	                UserList.erase(it1);
+	                umu.Unlock();
+
+                                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//					//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+
+	                return 0;
+				}
+			}
+			if(it1 == UserList.end())
+	        {
+		       
+		        
+		        umu.Unlock();
+		        return 1;
+	        }
+		}
+	}	
+	if(it == UserList.end())
+	{
+		
+		
+		umu.Unlock();
+		return 1;
+	}	
+}
+
+int CAdminServer::rclTeacherCreateGroup(CRCLCreateGroup *pMSG, SOCKET s)
+{
+
+	char textbuf[TEXTBUFFERLEN];
+	
+	rclTeacherList::iterator itt;
+	tmu.Lock();
+
+	for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+	{
+		if((*itt)->rclTeacherID == pMSG->TeacherID)
+		{
+
+			sprintf(textbuf,ptcher_crclass,(*itt)->rclName,pMSG->GroupName);  
+	        tmu.Unlock();
+
+	      
+	        DWORD GroupID = rclPopPushID(0);
+	        if(GroupID == 0)
+	        {
+
+				printf("no id\n");
+		        rclResponseError(10001,s,RCL_MAX_GROUP);
+		        return 1;
+	        }
+
+	        
+	        rclMCUList::iterator itm;
+	        DWORD MCUID = 0;
+	        mmu.Lock();
+	        for(itm=MCUList.begin();itm!=MCUList.end();++itm)
+	        {
+		        if(!(*itm)->rclRoomID)
+		        {
+			    
+			        MCUID = (*itm)->rclMCUID;
+
+			        (*itm)->rclRoomID = GroupID;
+			        break;
+		        }
+	        }
+	        mmu.Unlock();
+
+	        
+	        if(!MCUID)
+	        {
+
+				printf("no mcu\n");
+		        rclResponseError(10001,s,RCL_TEACHER_CREATE_GROUP_NOMCU);
+		        return 1;
+	        }
+
+	        
+	        CRCLRoom *pNode = new CRCLRoom;
+	        pNode->rclMCUID = MCUID;
+	        memcpy(pNode->rclName,pMSG->GroupName,128);
+	        pNode->rclRoomID = GroupID;
+	        pNode->rclTeacherID = pMSG->TeacherID;
+	        pNode->rclFocusUserID = 0;
+
+	        pNode->rclRoomMode = 1; 
+	
+	        pNode->cs.Init();
+	        pNode->ms.Init();
+
+	        rmu.Lock();
+	        RoomList.push_back(pNode);
+	        rmu.Unlock();
+
+    
+	        (*itt)->rclRoomID = GroupID;
+	        (*itt)->rclSAPort = pMSG->CAPort;
+	        (*itt)->rclSVPort = pMSG->CVPort;
+
+      
+	    
+	        CRCLMSG response;
+	        CRCLCreateGroupR res;
+	
+	       
+	        res.ResponseType = 0;
+	        res.TAPort = (*itm)->rclTAPort;
+	        res.TSPort = (*itm)->rclTSPort;
+	        res.TVPort = (*itm)->rclTVPort;
+	        res.GroupID = GroupID;
+	     
+	        memcpy(res.MCUIP,(*itm)->rclLocalIP,16);
+
+		
+	        response.rclType = 10001;
+	     
+	        response.msglen = sizeof(CRCLCreateGroupR);
+			//06.04.03
+	        rclMakePacket(response.msg,(char*)&res,response.msglen);
+	        
+
+	        rclSendResponse((char*)&response,response.msglen+8,&s,1);
+
+	       
+	        CRCLCreateGroupRMCU resm;
+	        resm.CAPort = (*itt)->rclSAPort;
+	        resm.CVPort = (*itt)->rclSVPort;
+	        resm.GroupID = (*itt)->rclRoomID;
+	        resm.TeacherID = (*itt)->rclTeacherID;
+	        memcpy(resm.GroupName,pMSG->GroupName,128);
+	        memcpy(resm.TeacherIP,(*itt)->rclIP,16);
+	        response.rclType = 10002;
+	        response.msglen = sizeof(CRCLCreateGroupRMCU);
+			//06.04.03
+	        rclMakePacket(response.msg,(char*)&resm,response.msglen);
+
+	        rclSendResponse((char*)&response,response.msglen+8,&(*itm)->s,1);
+                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//			//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+			return 0;
+		}
+	}
+	if(itt == TeacherList.end())
+	{
+		tmu.Unlock();
+		//06.04.03
+		rclResponseError(10001,s,RCL_TEACHER_CREATE_GROUP_FAIL);
+		return 1;
+	}	
+}
+
+int CAdminServer::rclTeacherLeaveGroup(CRCLDestroyGroup *pMSG, SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+	printf("step3\n");
+	
+	rclRoomList::iterator itr;
+	rmu.Lock();
+
+	for(itr = RoomList.begin();itr != RoomList.end();++itr)
+	{
+		if((*itr)->rclRoomID == pMSG->GroupID)
+		{
+			printf("step4\n");
+		
+	        SOCKET sk[2000];
+	        DWORD skn = 1;
+	        std::list<DWORD>::iterator itd;
+	      
+	        (*itr)->cs.Lock();
+			printf("enter cs lock\n");
+	        for(itd = (*itr)->rclUserRoom.begin();itd != (*itr)->rclUserRoom.end();++itd)
+	        {
+				printf("step5\n");
+		        rclUserList::iterator itu;
+		       
+				umu.Lock();
+
+		        for(itu = UserList.begin();itu != UserList.end();++itu)
+				{
+					if((*itu)->rclClientID == *itd)
+					{
+						
+		                (*itu)->rclRoomID = 0;
+		                
+		                if((*itu)->rclIfSeMCU == 1)
+		                {
+							printf("nothing\n");							
+			              
+
+		                }
+
+		                sk[skn] = (*itu)->s;
+		                skn++;
+						break;
+						
+					}
+				}
+				if(itu == UserList.end())
+		        {
+					printf("no user\n");
+					umu.Unlock();
+			        (*itr)->cs.Unlock();
+			        rmu.Unlock();
+
+			        rclResponseError(10011,s,RCL_TEACHER_LEAVE_GROUP_FAIL);
+			        return 1;
+		        }
+				umu.Unlock();
+			}
+		
+	        (*itr)->rclUserRoom.clear();
+	        (*itr)->cs.Unlock();
+
+	       
+	        (*itr)->ms.Lock();
+	        for(itd = (*itr)->rclSeMCURoom.begin();itd != (*itr)->rclSeMCURoom.end();++itd)
+	        {
+				printf("step6\n");
+		        rclSeMCUList::iterator its;
+		        smu.Lock();
+		        
+
+		        for(its = SeMCUList.begin();its != SeMCUList.end();++its)
+		        {
+					printf("step12\n");
+			        if((*its)->rclMCUID == *itd)
+			        {
+				    
+		                (*its)->rclRoomID = 0;
+		                sk[skn] = (*its)->s;
+		
+		                SeMCUList.erase(its);
+		                delete (*its);
+		                (*its) = NULL;
+		
+		                skn++;
+						break;
+
+			        }
+		        }
+				
+		        if(its == SeMCUList.end())
+		        {
+					printf("no seMCU\n");
+			        smu.Unlock();
+			        (*itr)->ms.Unlock();
+			        rmu.Unlock();
+
+			        rclResponseError(10011,s,10001);
+			        return 1;
+		        }	
+				smu.Unlock();				
+	        }
+
+	        
+			printf("step11\n");
+	        (*itr)->rclSeMCURoom.clear();
+	        (*itr)->ms.Unlock();
+
+	       
+	        rclTeacherList::iterator itt;
+	        tmu.Lock();
+
+	        for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+	        {
+		        if((*itt)->rclTeacherID == pMSG->TeacherID)
+		        {
+					sprintf(textbuf,ptcher_canlclass,(*itt)->rclName);  
+					printf("step7\n");
+			        (*itt)->rclRoomID = 0;
+
+	                tmu.Unlock();
+					
+	        		rclMCUList::iterator itm;
+	        		mmu.Lock();
+
+	        		for(itm = MCUList.begin();itm != MCUList.end();++itm)
+	        		{
+						printf("step8\n");
+		        		if((*itm)->rclMCUID == (*itr)->rclMCUID)
+		        		{
+			        		(*itm)->rclRoomID = 0;
+	                		
+	                		sk[0] = (*itm)->s;
+	                		mmu.Unlock();
+
+	                		
+
+
+	                		rclPopPushID((*itr)->rclRoomID);
+
+	                		delete (*itr);
+	                		(*itr) = NULL;
+	                		RoomList.erase(itr);
+	                		rmu.Unlock();
+			        		
+	                		
+	                		CRCLMSG response;
+	                		CRCLDestroyGroupR res;
+	
+	                		res.ResponseType = 0;
+	                		response.rclType = 10011;
+	                		response.msglen = sizeof(CRCLDestroyGroupR);
+
+	                		rclMakePacket(response.msg,(char*)&res,response.msglen);
+
+	                		rclSendResponse((char*)&response,response.msglen+8,&s,1);
+	
+	                		
+	                		CRCLDestroyGroupRClient resM;
+	                		resM.GroupID = pMSG->GroupID;
+	                		response.rclType = 10012;
+	                		response.msglen = sizeof(CRCLDestroyGroupRClient);
+
+	                		rclMakePacket(response.msg,(char*)&resM,response.msglen);
+
+	                		rclSendResponse((char*)&response,response.msglen+8,sk,skn);
+                                                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//							//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+
+
+
+
+
+	                		return 0;
+		        		}
+	        		}
+	        		if(itm == MCUList.end())
+	        		{
+		       			mmu.Unlock();
+		        		rmu.Unlock();
+		        		//06.04.03
+		        		rclResponseError(10011,s,RCL_TEACHER_LEAVE_GROUP_FAIL);
+		        		return 1;
+	        		}		
+		        }
+	        }
+	        if(itt == TeacherList.end())
+	        {
+				printf("can't find teacher\n");
+		        tmu.Unlock();
+		        rmu.Unlock();
+		        //06.04.03
+		        rclResponseError(10011,s,RCL_TEACHER_LEAVE_GROUP_FAIL);
+		        return 1;
+	        }	        		
+		}
+		if(itr == RoomList.end())
+	    {
+		    rmu.Unlock();
+		    rclResponseError(10011,s,RCL_TEACHER_LEAVE_GROUP_FAIL);
+		    return 1;
+	    }		
+	}
+    rmu.Unlock();
+    return 1;	
+}
+
+int CAdminServer::rclClientJoinGroup(CRCLClientJoinInGroup *pMSG, SOCKET s)
+{//1
+	char textbuf[TEXTBUFFERLEN];
+	
+	rmu.Lock();
+	rclRoomList::iterator itr;
+
+	for(itr = RoomList.begin();itr != RoomList.end();++itr)
+	{//2
+		if((*itr)->rclRoomID == pMSG->GroupID)
+		{//3
+			printf("find room\n");
+			DWORD RoomMode;
+	        RoomMode = (*itr)->rclRoomMode;
+	
+	        rmu.Unlock();
+	
+	       
+	        rclUserList::iterator itb;
+	        umu.Lock();
+
+	        for(itb = UserList.begin();itb != UserList.end();++itb)
+			{//4
+				if((*itb)->rclClientID == pMSG->ClientID)
+				{//5
+					sprintf(textbuf,pstu_join,(*itb)->rclName,(*itr)->rclName);
+					if((*itb)->rclRoomID)
+	                {//6
+		              
+						printf("have joined\n");
+		                umu.Unlock();
+
+		                rclResponseError(10021,s,RCL_STUDENT_JOIN_GROUP_FAIL);
+		                return 1;
+	                }//6
+
+	               
+	
+	                (*itb)->rclTVPort = pMSG->TVPort;
+	                (*itb)->rclTAPort = pMSG->TAPort;
+	                (*itb)->rclTSPort = pMSG->TSPort;
+	                (*itb)->rclSVPort = pMSG->CVPort;
+	                (*itb)->rclSAPort = pMSG->CAPort;
+
+	                (*itb)->rclRoomID = pMSG->GroupID;
+	                umu.Unlock();
+
+	               
+	                CRCLClientJoinInGroupR res;
+	                DWORD ClientNum = 0;
+	                DWORD SocketNum = 0;
+	                SOCKET skk[300];
+	              
+	                rclTeacherList::iterator itt;
+	                tmu.Lock();
+
+	                for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+					{//7
+						if((*itt)->rclTeacherID == (*itr)->rclTeacherID)
+						{//8
+							printf("find teacher s\n");
+							skk[SocketNum] = (*itt)->s;
+	                        SocketNum++;
+	                        tmu.Unlock();
+
+	                       
+	                        std::list<DWORD>::iterator itc;
+	                        (*itr)->cs.Lock();
+	                        for(itc=(*itr)->rclUserRoom.begin();itc!=(*itr)->rclUserRoom.end();++itc)
+	                        {//9
+		                      
+		                        rclUserList::iterator itu;
+		                        umu.Lock();
+
+		                        for(itu = UserList.begin();itu != UserList.end();++itu)
+								{//10
+									printf("%d\n",*itc);
+									if((*itu)->rclClientID == *itc)
+									{//11
+										printf("get client s\n");
+										
+		                                skk[SocketNum] = (*itu)->s;
+		                                SocketNum++;
+		                                ClientNum++;
+	
+		                                umu.Unlock();
+	                                }//11
+								}//10
+							
+							}//9
+
+	                     
+							printf("join group\n");
+	                        (*itr)->rclUserRoom.push_back(pMSG->ClientID);
+
+	                        (*itr)->cs.Unlock();
+	
+	                        
+	                        char rclClient_IP[16];
+	                        char rclClient_LocalIP[16];
+	                        char ClientPass[16];
+	                        DWORD ClientType;
+	                        SOCKET Client_s;
+	                        int Client_ThreadEvent;
+	                        CClientInfo ClientInfo;
+	                        DWORD SeMCU_TAPort;
+	                        DWORD SeMCU_TVPort;
+	                        DWORD SeMCU_TSPort;
+	                        DWORD SeMCU_SAPort;
+	                        DWORD SeMCU_SVPort;
+
+	                        rclUserList::iterator itu;
+	                        umu.Lock();
+	                        
+	                        for(itu = UserList.begin();itu != UserList.end();++itu)
+							{//12
+								if((*itu)->rclClientID == pMSG->ClientID)
+								{//13
+									
+									printf("get ip\n");
+                                    memcpy(rclClient_IP,(*itu)->rclIP,16);
+	                                memcpy(rclClient_LocalIP,(*itu)->rclLocalIP,16);
+	                                
+	                                ClientType = (*itu)->rclClientType;
+	                                memcpy(ClientPass,(*itu)->rclPass,16);
+	                                Client_s = (*itu)->s;
+	                                Client_ThreadEvent = (*itu)->ThreadEvent;
+	                                SeMCU_TVPort = (*itu)->rclSeMCU_TVPort;
+	                                SeMCU_TAPort = (*itu)->rclSeMCU_TAPort;
+	                                SeMCU_TSPort = (*itu)->rclSeMCU_TSPort;
+	                                SeMCU_SVPort = (*itu)->rclSeMCU_SVPort;
+	                                SeMCU_SAPort = (*itu)->rclSeMCU_SAPort;
+
+	                                ClientInfo.ClientID = pMSG->ClientID;
+	                                memcpy(ClientInfo.ClienName,(*itu)->rclName,NAMELEN);//06.10.11
+	                                ClientInfo.IsFocus = 1; 
+	                                umu.Unlock();
+	
+	                              
+	                                rclMCUList::iterator itm;
+	                                mmu.Lock();
+
+	                                for(itm = MCUList.begin();itm != MCUList.end();++itm)
+									{//14
+										if((*itm)->rclMCUID == (*itr)->rclMCUID)
+										{//15
+										
+	                                       
+											printf("send to client\n");
+	                                        CRCLMSG response;
+	                                        res.ResponseType = 0;
+	                                        res.GroupID = pMSG->GroupID;
+	
+	                                        res.TVPort = (*itm)->rclTVPort;
+	                                        res.TAPort = (*itm)->rclTAPort;
+	                                        res.TSPort = (*itm)->rclTSPort;
+	                                        res.CVPort = (*itm)->rclSVPort;
+	                                        res.CAPort = (*itm)->rclSAPort;
+	                                    
+	                                        res.RoomMode = RoomMode;
+	                                        memcpy(res.MCUIP,(*itm)->rclLocalIP,16);
+	                                        mmu.Unlock();
+	
+	                                        DWORD IfSeMCU;
+	                                        if (ClientType == 0)
+	                                        {//16
+	                                            memcpy(res.SeMCUIP,"",16); 
+	                                            IfSeMCU = 0;
+	                                        }//16
+	                                        else  
+	                                        {//17
+
+												printf("nei wang\n");
+	                                            rclSeMCUList::iterator itsem;
+	                                            smu.Lock();
+	                                            for (itsem = SeMCUList.begin();itsem != SeMCUList.end();++itsem)
+	                                            {//18
+		                                            //*********//
+													printf("search semcu\n");
+		                                            char rcltest_rclIP[16];
+		                                            memcpy(rcltest_rclIP,(*itsem)->rclIP,16);
+		                                            DWORD rcltest_rclIP_rclRoomID;
+		                                            rcltest_rclIP_rclRoomID = (*itsem)->rclRoomID;
+		                                            SOCKET rclSeMCU_s;
+		
+		                                            rclSeMCU_s = (*itsem)->s;
+		                                            if (strcmp((*itsem)->rclIP,rclClient_IP) == 0 && (*itsem)->rclRoomID == pMSG->GroupID)  //该内网同一组中已经存在一个辅MCU
+		                                            { //19  
+		                                                IfSeMCU = 0; 
+		                                                memcpy(res.SeMCUIP,(*itsem)->rclLocalIP,16); 
+		                                                //********//
+		                                                CRCLClientJoinInGroupRSeMCU resSeM;
+		                                                resSeM.ClientID = pMSG->ClientID;
+		                                                memcpy(resSeM.ClientIP,rclClient_LocalIP,16);
+		                                                resSeM.TVPort = pMSG->TVPort;
+		                                                resSeM.TAPort = pMSG->TAPort;
+		                                                resSeM.TSPort = pMSG->TSPort;
+		                                                resSeM.CVPort = pMSG->CVPort;
+		                                                resSeM.CAPort = pMSG->CAPort;
+		    
+		                                                response.rclType = 10024;
+		                                                response.msglen = sizeof(CRCLClientJoinInGroupRSeMCU);
+		                                                rclMakePacket(response.msg,(char*)&resSeM,response.msglen);
+		                                                rclSendResponse((char*)&response,response.msglen+8,&rclSeMCU_s,1);
+
+		                                                break;
+		                                            }//19
+	                                             }//18
+	                                             smu.Unlock();
+
+	                                             if(itsem == SeMCUList.end())
+	                                             {//20
+		                                             IfSeMCU =1; 
+		                                             memcpy(res.SeMCUIP,rclClient_IP,16);
+													 printf("no semcu for this user");
+													 return 1;
+		                                             
+		
+
+
+	                                             }//20
+
+
+	                                        }//17
+	
+	                                        										
+	                                        umu.Lock();
+											rclUserList::iterator itu1;
+
+	                                        for(itu1 = UserList.begin();itu1 != UserList.end();++itu1)
+											{//21
+												if((*itu1)->rclClientID == pMSG->ClientID)
+												{//22
+													printf("send to other\n");
+													(*itu1)->rclIfSeMCU = IfSeMCU;
+	                                                umu.Unlock();
+	
+
+
+	                                                response.rclType = 10021;
+	                                                response.msglen = sizeof(CRCLClientJoinInGroupR);
+	                                                rclMakePacket(response.msg,(char*)&res,response.msglen);
+	                                                rclSendResponse((char*)&response,response.msglen+8,&s,1);
+                                                                                                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//													//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+	
+	                                               
+	                                          
+	                                                CRCLClientJoinInGroupRAll resA;
+	                                                resA.ClientInfo = ClientInfo;
+	                                                response.rclType = 10022;
+	                                                response.msglen = sizeof(CRCLClientJoinInGroupRAll);
+	                                                rclMakePacket(response.msg,(char*)&resA,response.msglen);
+
+	                                                rclSendResponse((char*)&response,response.msglen+8,skk,SocketNum);
+	
+	                                               
+	                                                CRCLClientJoinInGroupRMCU resM;
+
+	                                              
+
+	                                             
+
+                                                    DWORD ID_MCU; //
+	                                                char ip_Client[16]; //
+	                                                SOCKET s_MCU;
+	                                                if (IfSeMCU == 0)
+	                                                {//23
+														printf("choose mcu\n");
+	                                                   
+	                                                    memset(ip_Client,0,16);
+	                                                    if(rclChooseMCU(pMSG->ClientID,pMSG->GroupID,&s_MCU,ip_Client,&ID_MCU))
+	                                                    {//24
+		                                                    
+															printf("choose mcu error\n");
+		                                                    return 1;
+	                                                    }//24
+	                                                    
+	                                                    resM.TVPort = pMSG->TVPort;
+	                                                    resM.TAPort = pMSG->TAPort;
+	                                                    resM.TSPort = pMSG->TSPort;
+	                                                    resM.CVPort = pMSG->CVPort;
+	                                                    resM.CAPort = pMSG->CAPort;	   
+	                                                }//23
+	                                                else
+	                                                {//25
+														printf("main mcu\n");
+	                                                    ID_MCU = pMSG->ClientID;
+	                                                    memcpy(ip_Client,rclClient_IP,16);
+	                                                    mmu.Lock();
+	                                                    s_MCU = (*itm)->s;
+	                                                    mmu.Unlock();
+	                                                    
+	  
+	                                                    resM.TVPort = SeMCU_TVPort;
+	                                                    resM.TAPort = SeMCU_TAPort;
+	                                                    resM.TSPort = SeMCU_TSPort;
+	                                                    resM.CVPort = SeMCU_SVPort;
+	                                                    resM.CAPort = SeMCU_SAPort;	  
+	                                                }//25
+
+	                                              
+	                                                umu.Lock();
+													rclUserList::iterator itu2;
+
+	                                                for(itu2 = UserList.begin();itu2 != UserList.end();++itu2)
+													{//26
+														if((*itu2)->rclClientID == pMSG->ClientID)
+														{//27
+															printf("change mcu id\n");
+															(*itu2)->rclMCUID = ID_MCU;
+	                                                        umu.Unlock();
+
+	                                                        
+	                                                        
+	                                                        resM.ClientInfo = ClientInfo;
+
+	                                                        memcpy(resM.ClientIP,ip_Client,16);
+
+	                                                        resM.ClientType = ClientType;
+	
+	                                                        response.rclType = 10023;
+	
+	                                                        response.msglen = sizeof(CRCLClientJoinInGroupRMCU);
+	                                                        rclMakePacket(response.msg,(char*)&resM,response.msglen);
+															
+	                                                        rclSendResponse((char*)&response,response.msglen+8,&s_MCU,1);
+															
+															
+	                                                        return 0;
+														}//27
+													}//26
+													if(itu2 == UserList.end())
+	                                                {//28
+														printf("error 1\n");
+		                                                umu.Unlock();
+		                                                mmu.Unlock();
+		                                                return 1;
+	                                                }//28
+												}//22
+											}//21
+											if(itu1 == UserList.end())
+	                                        {
+												printf("error 2\n");
+	                                            umu.Unlock();
+	                                            return 1;
+	                                        }
+										}//15
+									}//14												
+	                                if(itm == MCUList.end())
+	                                {
+										printf("error 3\n");
+		                                mmu.Unlock();
+		                                rclResponseError(10021,s,RCL_STUDENT_JOIN_GROUP_FAIL);
+		                                return 1;
+	                                }
+								}//13
+							}//12										
+	                        if(itu == UserList.end())
+	                        {
+								printf("error 4\n");
+	                            umu.Unlock();
+	                            return 1;
+	                        }                            
+                        }//8
+                    }//7						
+	                if(itt == TeacherList.end())
+	                {
+						printf("error 6\n");
+		                tmu.Unlock();
+		                rclResponseError(10021,s,RCL_STUDENT_JOIN_GROUP_FAIL);
+		                return 1;
+	                }
+                }//5
+            }//4				
+			if(itb == UserList.end())
+	        {
+				printf("error 7\n");
+		        umu.Unlock();
+		        rclResponseError(10021,s,RCL_STUDENT_JOIN_GROUP_FAIL);
+		        return 1;
+	        }
+        }//3
+    }//2		
+	if(itr == RoomList.end())
+	{
+		printf("error 8\n");
+		rmu.Unlock();
+		rclResponseError(10021,s,RCL_STUDENT_JOIN_GROUP_FAIL);
+		return 1;
+	}	
+}//1
+
+int CAdminServer::rclClientLeaveGroup(CRCLClientLeaveGroup *pMSG, SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+	
+	printf("here1\n");
+	rclRoomList::iterator itr;
+	rmu.Lock();
+
+	for(itr = RoomList.begin();itr != RoomList.end();++itr)
+	{
+		printf("%d\n",pMSG->GroupID);
+		printf("%d\n",(*itr)->rclRoomID);
+		if((*itr)->rclRoomID == pMSG->GroupID)
+		{
+			
+			printf("here2\n");
+	        if((*itr)->rclFocusUserID == pMSG->ClientID)
+	        {
+		        (*itr)->rclFocusUserID = 0;
+	        }
+
+	        std::list<DWORD>::iterator itd;
+	        (*itr)->cs.Lock();
+
+	        for(itd = (*itr)->rclUserRoom.begin();itd != (*itr)->rclUserRoom.end();++itd)
+			{
+				if((*itd) == pMSG->ClientID)
+				{
+					
+					printf("here3\n");
+
+	                (*itr)->rclUserRoom.erase(itd);
+	                (*itr)->cs.Unlock();
+	                rmu.Unlock();
+
+	                
+	                rclUserList::iterator itc;
+	                umu.Lock();
+
+	                for(itc = UserList.begin();itc != UserList.end();++itc)
+					{
+						if((*itc)->rclClientID == pMSG->ClientID)
+						{
+							sprintf(textbuf,pstu_out,(*itc)->rclName,(*itr)->rclName);  
+							
+							printf("here4\n");
+	                        (*itc)->rclRoomID = 0;
+	                         
+	                        DWORD mid = (*itc)->rclMCUID;
+
+	                        
+	                        DWORD ifSeMCU = (*itc)->rclIfSeMCU;
+
+
+
+	                        umu.Unlock();
+	
+	                        
+	                        CClientInfo ClientInfo;
+	                        strcpy(ClientInfo.ClienName,"ByeBye");
+	                        ClientInfo.ClientID = pMSG->ClientID;
+	                        ClientInfo.IsFocus = 1;
+
+	                        
+	                        SOCKET sk[2000];
+	                        DWORD skn = 0;
+	                        rclTeacherList::iterator itt;
+	                        tmu.Lock();
+
+	                        for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+						    {
+								if((*itt)->rclTeacherID == (*itr)->rclTeacherID)
+								{
+									printf("here5\n");
+									sk[skn] = (*itt)->s;
+	                                skn++;
+	                                tmu.Unlock();
+		
+	                                //MCU SOCKET
+	                                rclMCUList::iterator itm;
+	                                mmu.Lock();
+
+	                                for(itm = MCUList.begin();itm != MCUList.end();++itm)
+									{
+										if((*itm)->rclMCUID == mid)
+										{
+										    if(itm != MCUList.end())
+	                                        {
+		                                        
+		                                        sk[skn] = (*itm)->s;
+		                                        skn++;
+
+												printf("skn:%d\n",skn);	                                       
+												}
+											else
+											{
+
+		                            			rclSeMCUList::iterator its;
+		                            			smu.Lock();
+
+		                            			for(its = SeMCUList.begin();its != SeMCUList.end();++its)
+												{
+													if((*its)->rclMCUID == mid)
+													{
+														if(its == SeMCUList.end())
+		                            					{
+			                            					
+			                            					
+			                            					sk[skn] = 0;
+			                            					skn++;
+			                            					
+		                            					}
+														else{														
+															
+			                                				sk[skn] = (*its)->s;
+			                                				skn++;
+														}
+														
+													}
+													
+												}
+												smu.Unlock();
+											}												
+										}
+									}
+									mmu.Unlock();
+									
+	
+
+	                                
+	                                rmu.Lock();
+									rclRoomList::iterator itr1;
+
+	                                for(itr1 = RoomList.begin();itr1 != RoomList.end();++itr1)
+									{
+										printf("%d\n",pMSG->GroupID);
+										printf("%d\n",(*itr1)->rclRoomID);
+										if((*itr1)->rclRoomID == pMSG->GroupID)
+										{
+											printf("here 13\n");
+											std::list<DWORD>::iterator itd1;
+											(*itr)->cs.Lock();
+											for(itd1 = (*itr1)->rclUserRoom.begin();itd1 != (*itr1)->rclUserRoom.end();++itd1)
+	                                        {
+												printf("here6\n");
+		                                        rclUserList::iterator itu;
+
+
+		                                        for(itu = UserList.begin();itu != UserList.end();++itu)
+												{
+													if(itu == UserList.end())
+		 											{
+														printf("here8\n");
+														(*itr1)->cs.Unlock();
+														rmu.Unlock();
+														rclResponseError(10031,s,RCL_STUDENT_LEAVE_GROUP_FAIL);
+														return 1;
+													}
+													if((*itu)->rclClientID == *itd1)
+													{
+														printf("here7\n");
+														if((*itu)->rclClientID == pMSG->ClientID)
+		                                                {
+			                                                
+			                                                continue;
+		                                                }
+		                                                sk[skn] = (*itu)->s;
+		                                                skn++;
+		                                                //
+	                                                }
+												}
+											}
+											(*itr1)->cs.Unlock();	
+	                                        rmu.Unlock();
+
+	                                        
+											CRCLMSG response;
+											CRCLClientLeaveGroupRAll res;
+											res.ClientInfo = ClientInfo;
+											response.rclType = 10032;
+											response.msglen = sizeof(CRCLClientLeaveGroupRAll);
+											rclMakePacket(response.msg,(char*)&res,response.msglen);
+											printf("client leave group\n");
+											rclSendResponse((char*)&response,response.msglen+8,sk,skn);
+
+													
+											
+											CRCLClientLeaveGroupRAll resM;
+											resM.ClientInfo = ClientInfo;
+											response.rclType = 10033;
+											response.msglen = sizeof(CRCLClientLeaveGroupRAll);
+											rclMakePacket(response.msg,(char*)&resM,response.msglen);
+											printf("client leave group , send to mcu\n");
+											rclSendResponse((char*)&response,response.msglen+8,&sk[1],1);
+
+
+											
+											CRCLClientLeaveGroupR resR;
+											resR.ResponseType = 0;
+											resR.GroupID = 0;
+											response.rclType = 10031;
+											response.msglen = sizeof(CRCLClientLeaveGroupR);
+											rclMakePacket(response.msg,(char*)&resR,response.msglen);
+											printf("client leave group, send to this client\n");
+											rclSendResponse((char*)&response,response.msglen+8,&s,1);
+                                                                                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//											//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+
+
+											return 0;
+										}
+									}		
+									if(itr1 == RoomList.end())
+									{
+										printf("here9\n");
+										rmu.Unlock();
+										rclResponseError(10031,s,RCL_STUDENT_LEAVE_GROUP_FAIL);
+										return 1;
+									}
+								}
+							}	
+							if(itt == TeacherList.end())
+							{
+								printf("here10\n");
+								tmu.Unlock();
+								rclResponseError(10031,s,RCL_STUDENT_LEAVE_GROUP_FAIL);
+								return 1;
+							}
+						}
+					}	
+					if(itc == UserList.end())
+					{
+						printf("here11\n");
+						umu.Unlock();
+						rclResponseError(10031,s,RCL_STUDENT_LEAVE_GROUP_FAIL);
+						return 1;
+					}
+				}
+			}	
+			if(itd == (*itr)->rclUserRoom.end())
+			{
+				printf("here12\n");
+				(*itr)->cs.Unlock();
+				rmu.Unlock();
+				rclResponseError(10031,s,RCL_STUDENT_LEAVE_GROUP_FAIL);
+				return 1;
+			}
+		}
+	}	
+	if(itr == RoomList.end())
+	{
+		printf("here13\n");
+		rmu.Unlock();
+		rclResponseError(10031,s,RCL_STUDENT_LEAVE_GROUP_FAIL);
+		return 1;
+	}	
+}
+
+int CAdminServer::rclMakePacket(char *pResponse, char *pRes, DWORD len)
+{
+	
+	
+	memcpy(pResponse,pRes,len);
+	return 0;
+}
+
+int CAdminServer::rclSendResponse(char *pbuf, DWORD len, SOCKET *s, DWORD nums)
+{
+	char *buffer;
+	DWORD bytesent = 0;
+
+	buffer = (char*)malloc(len);
+	memcpy(buffer, pbuf, len);
+	
+	int i = 0;
+    CAsyncSocketEx asy;
+
+	
+	for(i=0;i<nums;i++)
+	{
+		if(s[i])
+		{
+			asy.Attach(s[i], 0);
+            asy.Send(buffer, len, 0);
+			asy.Detach();
+		}
+	}
+
+	free(buffer);
+	return 0;
+}
+
+int CAdminServer::rclMCULeaveGroup(CRCLMCULeaveGroup *pMSG,SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+	
+	rclMCUList::iterator itm;
+	mmu.Lock();
+
+	for(itm = MCUList.begin();itm != MCUList.end();++itm)
+	{
+		if((*itm)->rclMCUID == pMSG->MCUID)
+		{
+			
+			mmu.Unlock();
+
+			
+			rclRoomList::iterator itr;
+			rmu.Lock();
+
+			for(itr = RoomList.begin();itr != RoomList.end();++itr)
+			{
+				if((*itr)->rclRoomID == pMSG->GroupID)
+				{
+					sprintf(textbuf,prmcu_exit_class,(*itm)->rclName,(*itr)->rclName);  
+					
+					SOCKET sk[2000];
+					DWORD skn = 1;
+					DWORD SeMCUID;
+					std::list<DWORD>::iterator itd;
+					
+					(*itr)->cs.Lock();
+					for(itd=(*itr)->rclUserRoom.begin();itd!=(*itr)->rclUserRoom.end();++itd)
+					{
+						rclUserList::iterator itu;
+						
+
+						for(itu = UserList.begin();itu != UserList.end();++itu)
+						{
+							if((*itu)->rclClientID == *itd)
+							{
+								
+								(*itu)->rclRoomID = 0;
+								sk[skn] = (*itu)->s;
+								skn++;
+								if ((*itu)->rclIfSeMCU == 1)
+									SeMCUID = (*itu)->rclClientID;
+
+							}
+							if(itu == UserList.end())
+							{
+								(*itr)->cs.Unlock();
+								rmu.Unlock();
+								rclResponseError(10011,s,RCL_TEACHER_LEAVE_GROUP_FAIL);
+								return 1;
+							}
+						}
+					}
+					
+					(*itr)->rclUserRoom.clear();
+					(*itr)->cs.Unlock();
+	
+					
+					(*itr)->ms.Lock();
+					for(itd=(*itr)->rclSeMCURoom.begin();itd!=(*itr)->rclSeMCURoom.end();++itd)
+					{
+						rclSeMCUList::iterator its;
+						
+
+						for(its = SeMCUList.begin();its != SeMCUList.end();++its)
+						{
+							if((*its)->rclMCUID == *itd)
+							{
+								
+								(*its)->rclRoomID = 0;
+								sk[skn] = (*its)->s;
+								skn++;
+																
+							}
+							if(its == SeMCUList.end())
+							{
+								(*itr)->ms.Unlock();
+								rmu.Unlock();
+								rclResponseError(10011,s,10001);
+								return 1;
+							}
+						}
+					}
+					
+					(*itr)->rclSeMCURoom.clear();
+					(*itr)->ms.Unlock();
+	
+					
+					rclTeacherList::iterator itt;
+					printf("enter tmu lock\n");
+					tmu.Lock();
+
+					for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+					{
+						if((*itt)->rclTeacherID == (*itr)->rclTeacherID)
+						{
+							(*itt)->rclRoomID = 0;
+	                        sk[0] = (*itt)->s;
+							printf("leave tmu lock\n");
+	                        tmu.Unlock();
+	
+	                        
+	                        mmu.Lock();
+							rclMCUList::iterator itm1;
+
+	                        for(itm1 = MCUList.begin();itm1 != MCUList.end();++itm1)
+							{
+								if((*itm1)->rclMCUID == (*itr)->rclMCUID)
+								{
+									(*itm1)->rclRoomID = 0;
+									mmu.Unlock();
+	
+									
+
+									rclPopPushID((*itr)->rclRoomID);
+									printf("delete1\n");
+									delete (*itr);
+									printf("delete2\n");
+									(*itr) = NULL;
+									printf("delete3\n");
+									RoomList.erase(itr);
+									rmu.Unlock();
+	
+									
+									
+									CRCLMSG response;
+									CRCLMCULeaveGroupR res;
+	
+									res.ResponseType = 0;
+									response.rclType = 10041;
+									response.msglen = sizeof(CRCLMCULeaveGroupR);
+									rclMakePacket(response.msg,(char*)&res,response.msglen);
+									printf("MCU leave group\n");
+									rclSendResponse((char*)&response,response.msglen+8,&s,1);
+	
+									
+									CRCLMCULeaveGroupRAll resM;
+									resM.GroupID = pMSG->GroupID;
+									response.rclType = 10042;
+									response.msglen = sizeof(CRCLDestroyGroupRClient);
+									rclMakePacket(response.msg,(char*)&resM,response.msglen);
+									rclSendResponse((char*)&response,response.msglen+8,sk,skn);
+                                                                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//									//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+									return 0;
+								}
+							}
+							if(itm1 == MCUList.end())
+							{
+								mmu.Unlock();
+
+								return 1;
+							}
+						}
+					}	
+					if(itt == TeacherList.end())
+					{
+						tmu.Unlock();
+						rclResponseError(10011,s,RCL_TEACHER_LEAVE_GROUP_FAIL);
+						return 1;
+					}
+				}
+			}				
+			if(itr == RoomList.end())
+			{
+				rmu.Unlock();
+				rclResponseError(10011,s,RCL_TEACHER_LEAVE_GROUP_FAIL);
+				return 1;
+			}
+		}
+	}		
+	if(itm  == MCUList.end())
+	{
+		mmu.Unlock();
+		rclResponseError(10041,s,RCL_MCU_LEAVE_GROUP_FAIL);
+		return 1;
+	}	
+}
+
+int CAdminServer::rclTeacherTextBroadcast(CRCLTeacherTextBroadcast *pMSG, SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+	
+	rclRoomList::iterator itr;
+	rmu.Lock();
+
+	for(itr = RoomList.begin();itr != RoomList.end();++itr)
+	{
+		if((*itr)->rclRoomID == pMSG->GroupID)
+		{
+			
+			SOCKET sk[2000];
+			DWORD skn = 0;
+			DWORD SeMCUID ;
+	
+			
+			std::list<DWORD>::iterator itd;
+			
+			(*itr)->cs.Lock();
+			for(itd=(*itr)->rclUserRoom.begin();itd!=(*itr)->rclUserRoom.end();++itd)
+			{
+				rclUserList::iterator itu;
+				
+				umu.Lock();
+
+		 		for(itu = UserList.begin();itu != UserList.end();++itu)
+				{
+					if((*itu)->rclClientID == *itd)
+					{
+						sk[skn] = (*itu)->s;
+						skn++;
+						if ((*itu)->rclIfSeMCU == 1)
+							SeMCUID = (*itu)->rclClientID;
+						umu.Unlock();
+					}
+				}
+				
+			}
+			(*itr)->cs.Unlock();
+
+			
+			(*itr)->cs.Lock();
+			for(itd=(*itr)->rclSeMCURoom.begin();itd!=(*itr)->rclSeMCURoom.end();++itd)
+			{
+				rclSeMCUList::iterator its;
+				
+				smu.Lock();
+
+				for(its = SeMCUList.begin();its != SeMCUList.end();++its)
+				{
+					if((*its)->rclMCUID == *itd)
+					{
+						if ((*its)->rclMCUID != SeMCUID)
+						{
+							
+							sk[skn] = (*its)->s;
+							skn++;
+						}
+						smu.Unlock();
+					}
+				}
+				
+			}
+			(*itr)->cs.Unlock();
+
+			rmu.Unlock();
+	
+			
+			CRCLTeacherTextBroadcastR res;
+			CRCLMSG response;
+			
+			rclTeacherList::iterator itt;
+			tmu.Lock();
+
+			for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+			{
+				if((*itt)->rclTeacherID == pMSG->ClientID)
+				{
+					sprintf(textbuf,pteacher_send_groupmage,(*itt)->rclName);  
+					memcpy(res.TeacherName,(*itt)->rclName,NAMELEN);//06.10.11
+					res.InfoLength = pMSG->InfoLength;
+					memcpy(res.Info,pMSG->Info,1024);
+
+					tmu.Unlock();
+
+					response.rclType = 1001;
+					response.msglen = sizeof(CRCLTeacherTextBroadcastR);
+					rclMakePacket(response.msg,(char*)&res,response.msglen);
+					printf("send text\n");
+					rclSendResponse((char*)&response,response.msglen+8,sk,skn);
+
+                                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//					//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+
+					return 0;
+				}
+			}
+			if(itt == TeacherList.end())
+			{
+				tmu.Unlock();
+				rclResponseError(1001,s,RCL_TEACHER_BROADCAST_TEXT_FAIL);
+				return 1;
+			}
+		}
+	}		
+	if(itr == RoomList.end())
+	{
+		rmu.Unlock();
+		rclResponseError(1001,s,RCL_TEACHER_BROADCAST_TEXT_FAIL);
+		return 1;
+	}	
+}
+
+int CAdminServer::rclTeacherSwitchMode(CRCLTeacherSwitchMode *pMSG, SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+	
+	rclRoomList::iterator itr;
+	rmu.Lock();
+
+	for(itr = RoomList.begin();itr != RoomList.end();++itr)
+	{
+		if((*itr)->rclRoomID == pMSG->GroupID)
+		{
+			
+			(*itr)->rclRoomMode = pMSG->ModeType;
+			if((*itr)->rclRoomMode == 0)
+			{
+				sprintf(textbuf,pclass_commu,(*itr)->rclName);  
+				ClientTalk = 1;
+			}
+			else
+			{
+				sprintf(textbuf,pclass_teach,(*itr)->rclName);  
+
+			}
+	
+			
+			SOCKET sk[2000];
+			DWORD skn = 0;
+	
+			
+			std::list<DWORD>::iterator itd;
+			
+			(*itr)->cs.Lock();
+			for(itd=(*itr)->rclUserRoom.begin();itd!=(*itr)->rclUserRoom.end();++itd)
+			{
+				rclUserList::iterator itu;
+				
+				umu.Lock();
+
+		 		for(itu = UserList.begin();itu != UserList.end();++itu)
+				{
+					if((*itu)->rclClientID == *itd)
+					{
+						sk[skn] = (*itu)->s;
+						skn++;
+						umu.Unlock();
+					}
+				}
+				
+			}
+			(*itr)->cs.Unlock();
+	
+			rmu.Unlock();
+
+			
+			CRCLTeacherSwitchModeR res;
+			CRCLMSG response;
+
+			res.ModeType = pMSG->ModeType;
+			response.rclType = 1081;
+			response.msglen = sizeof(CRCLTeacherSwitchModeR);
+			rclMakePacket(response.msg,(char*)&res,response.msglen);
+
+			rclSendResponse((char*)&response,response.msglen+8,sk,skn);
+                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//			//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+	
+			return 0;
+		}
+	}
+	if(itr == RoomList.end())
+	{
+		rmu.Unlock();
+		return 1;
+	}	
+}
+
+int CAdminServer::rclClientApplyFocus(CRCLClientApplyFocus *pMSG, SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+	
+	rclUserList::iterator itu;
+	umu.Lock();
+
+	for(itu = UserList.begin();itu != UserList.end();++itu)
+	{
+		if((*itu)->rclClientID == pMSG->ClientID)
+		{
+			umu.Unlock();
+			printf("find user\n");
+			sprintf(textbuf,pstu_appli,(*itu)->rclName);  
+
+			
+			rclRoomList::iterator itr;
+			rmu.Lock();
+
+			for(itr = RoomList.begin();itr != RoomList.end();++itr)
+			{
+				if((*itr)->rclRoomID == pMSG->GroupID)
+				{
+					printf("find room\n");
+					
+					SOCKET Teacher_s;
+					tmu.Lock();
+					rclTeacherList::iterator itt;
+
+					for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+					{
+						if((*itt)->rclTeacherID == (*itr)->rclTeacherID)
+						{
+							printf("send to teacher\n");
+							Teacher_s = (*itt)->s;
+							tmu.Unlock();
+							rmu.Unlock();
+	
+							
+							CRCLClientApplyFocusR res;
+							CRCLMSG response;
+
+							res.ResponseType = 0;
+							response.rclType = 1011;
+							response.msglen = sizeof(CRCLClientApplyFocusR);
+							rclMakePacket(response.msg,(char*)&res,response.msglen);
+							printf("student apply focus,send to the student\n");
+							rclSendResponse((char*)&response,response.msglen+8,&s,1);
+
+							
+							CRCLClientApplyFocusRToTM rest;
+	
+							rest.FocusClientID = pMSG->ClientID;
+							response.rclType = 1012;
+							response.msglen = sizeof(CRCLClientApplyFocusRToTM);
+					  		rclMakePacket(response.msg,(char*)&rest,response.msglen);
+							rclSendResponse((char*)&response,response.msglen+8,&Teacher_s,2);
+                                                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+//							//							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+
+							return 0;
+						}
+					}
+					if(itt == TeacherList.end())
+					{
+						
+						tmu.Unlock();
+						rmu.Unlock();
+						rclResponseError(1011,s,RCL_STUDENT_APPLY_FOCUS_FAIL);
+						return 1;
+					}
+				}
+			}				
+			if(itr == RoomList.end())
+			{
+				rmu.Unlock();
+				rclResponseError(1011,s,RCL_STUDENT_APPLY_FOCUS_FAIL);
+				return 1;
+			}
+		}
+	}		
+	if(itu == UserList.end())
+	{
+		umu.Unlock();
+		rclResponseError(1011,s,RCL_STUDENT_APPLY_FOCUS_FAIL);
+		return 1;
+	}	
+}
+
+int CAdminServer::rclClientDestroyFocus(CRCLClientDestroyFocus *pMSG, SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+	
+	rclUserList::iterator itu;
+	umu.Lock();
+
+	for(itu = UserList.begin();itu != UserList.end();++itu)
+	{
+		if((*itu)->rclClientID == pMSG->ClientID)
+		{
+			umu.Unlock();
+			sprintf(textbuf,pstu_appli_cancel,(*itu)->rclName);  
+	
+			
+			rclRoomList::iterator itr;
+			rmu.Lock();
+
+			for(itr = RoomList.begin();itr != RoomList.end();++itr)
+			{
+				if((*itr)->rclRoomID == pMSG->GroupID)
+				{
+					
+					if(!(*itr)->rclFocusUserID)
+					{
+						
+						rmu.Unlock();
+						rclResponseError(1021,s,RCL_STUDENT_KILL_FOCUS_FAIL);
+						return 1;
+					}
+
+					
+					SOCKET sk[2];
+					mmu.Lock();
+					rclMCUList::iterator itm;
+
+					for(itm = MCUList.begin();itm != MCUList.end();++itm)
+					{
+						if((*itm)->rclMCUID == (*itr)->rclMCUID)
+						{
+							sk[0] = (*itm)->s;
+							mmu.Unlock();
+	
+							tmu.Lock();
+							rclTeacherList::iterator itt;
+							for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+							{
+								if((*itt)->rclTeacherID == (*itr)->rclTeacherID)
+								{
+									sk[1] = (*itt)->s;
+									tmu.Unlock();
+
+
+									rmu.Unlock();
+
+									
+									CRCLClientDestroyFocusR res;
+									CRCLMSG response;
+	
+									res.ResponseType = 0;
+									response.rclType = 1021;
+									response.msglen = sizeof(CRCLClientDestroyFocusR);
+									rclMakePacket(response.msg,(char*)&res,response.msglen);
+									rclSendResponse((char*)&response,response.msglen+8,&s,1);
+
+									
+									CRCLClientDestroyFocusRToTM rest;
+	
+									rest.FocusClientID = pMSG->ClientID;
+									response.rclType = 1022;
+									response.msglen = sizeof(CRCLClientDestroyFocusRToTM);
+									rclMakePacket(response.msg,(char*)&rest,response.msglen);
+									rclSendResponse((char*)&response,response.msglen+8,sk,2);
+                                                                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+                                                                        //							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+	
+									return 0;
+								}
+							}
+							if(itt == TeacherList.end())
+							{
+								
+								tmu.Unlock();
+								rmu.Unlock();
+								rclResponseError(1011,s,RCL_STUDENT_APPLY_FOCUS_FAIL);
+								return 1;
+							}
+						}
+					}						
+					if(itm == MCUList.end())
+					{
+						
+						mmu.Unlock();
+						rmu.Unlock();
+						rclResponseError(1011,s,RCL_STUDENT_APPLY_FOCUS_FAIL);
+						return 1;
+					}
+				}
+			}				
+			if(itr == RoomList.end())
+			{
+				rmu.Unlock();
+				rclResponseError(1021,s,RCL_STUDENT_KILL_FOCUS_FAIL);
+				return 1;
+			}
+		}
+	}		
+	if(itu == UserList.end())
+	{
+		umu.Unlock();
+		rclResponseError(1021,s,RCL_STUDENT_KILL_FOCUS_FAIL);
+		return 1;
+	}	
+}
+
+int CAdminServer::rclClientTextBroadcast(CRCLClientTextBroadcast *pMSG, SOCKET s)
+{
+	if(ClientTalk == 1)
+	{
+		char textbuf[TEXTBUFFERLEN];
+		
+		rclRoomList::iterator itr;
+		rmu.Lock();
+
+		for(itr = RoomList.begin();itr != RoomList.end();++itr)
+		{
+			if((*itr)->rclRoomID == pMSG->GroupID)
+			{
+				
+				std::list<DWORD>::iterator itd;
+				
+				SOCKET sk[2000];
+				DWORD skn = 1;
+				DWORD SeMCUID;
+
+				
+				(*itr)->cs.Lock();
+				for(itd=(*itr)->rclUserRoom.begin();itd!=(*itr)->rclUserRoom.end();++itd)
+				{
+					rclUserList::iterator itu;
+					
+					umu.Lock();
+
+					for(itu = UserList.begin();itu != UserList.end();++itu)
+					{
+						if((*itu)->rclClientID == *itd)
+						{
+
+							sprintf(textbuf,pstu_send_groupmage,(*itu)->rclName); 
+
+							if((*itu)->rclIfSeMCU == 1)
+								SeMCUID= (*itu)->rclMCUID;
+
+			
+							
+							if((*itu)->rclClientID == pMSG->ClientID)
+							{
+								umu.Unlock();
+								continue;
+							}
+							
+							sk[skn] = (*itu)->s;
+							skn++;
+							umu.Unlock();
+						}
+					}
+					
+				}
+				(*itr)->cs.Unlock();
+
+	
+				
+				(*itr)->cs.Lock();
+				for(itd=(*itr)->rclSeMCURoom.begin();itd!=(*itr)->rclSeMCURoom.end();++itd)
+				{
+					rclSeMCUList::iterator its;
+					
+					smu.Lock();
+
+					for(its = SeMCUList.begin();its != SeMCUList.end();++its)
+					{
+						if((*its)->rclMCUID == *itd)
+						{
+							if ((*its)->rclMCUID != SeMCUID)
+							{
+								
+								sk[skn] = (*its)->s;
+								skn++;
+							}
+							smu.Unlock();
+						}
+					}
+					
+				}
+				(*itr)->cs.Unlock();
+				rmu.Unlock();
+
+				
+				rclTeacherList::iterator itt;
+				tmu.Lock();
+
+				for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+				{
+					if((*itt)->rclTeacherID == (*itr)->rclTeacherID)
+					{
+						sk[0] = (*itt)->s;
+						tmu.Unlock();
+	
+						
+						CRCLClientTextBroadcastR res;
+						CRCLMSG response;
+						
+						rclUserList::iterator itu;
+						umu.Lock();
+
+						for(itu = UserList.begin();itu != UserList.end();++itu)
+						{
+							if((*itu)->rclClientID == pMSG->ClientID)
+							{
+								memcpy(res.ClientName,(*itu)->rclName,NAMELEN);//06.10.11
+								umu.Unlock();
+
+								
+
+								
+								memcpy(res.Info,pMSG->Info,1024);
+								response.rclType = 1031;
+								response.msglen = sizeof(CRCLClientTextBroadcastR);
+								int skk = 0;
+								
+									
+									rclMakePacket(response.msg,(char*)&res,response.msglen);
+									rclSendResponse((char*)&response,response.msglen+8,sk,skn);
+
+
+                                                                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+                                                                        //							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+									
+	
+								return 0;
+							}
+						}
+						if(itu == UserList.end())
+						{
+							umu.Unlock();
+							rclResponseError(1031,s,RCL_STUDENT_BROADCAST_TEXT_FAIL);
+							return 1;
+						}
+					}
+				}				
+				if(itt == TeacherList.end())
+				{
+					tmu.Unlock();
+					rclResponseError(1031,s,RCL_STUDENT_BROADCAST_TEXT_FAIL);
+					return 1;
+				}
+			}
+		}		
+		if(itr == RoomList.end())
+		{
+			rmu.Unlock();
+			rclResponseError(1031,s,RCL_STUDENT_BROADCAST_TEXT_FAIL);
+			return 1;
+		}
+	}
+	else
+		return 1;
+}
+
+int CAdminServer::rclResponseError(DWORD MSGType, SOCKET s, DWORD et)
+{
+	
+	CRCLMSG response;
+	DWORD result = et;
+
+	response.rclType = MSGType;
+	response.msglen = sizeof(DWORD);
+	memcpy(response.msg,&result,sizeof(DWORD));
+	
+	
+	rclSendResponse((char*)&response,response.msglen+8,&s,1);
+	
+	
+
+	return 0;
+}
+
+
+DWORD CAdminServer::rclPopPushID(DWORD id)
+{
+	 
+	
+	rclIDList::iterator iti;
+	if(id)
+	{
+		
+		
+		dmu.Lock();
+
+		for(iti = IDList.begin();iti != IDList.end();++iti)
+		{
+			if((*iti) == id)
+			{
+				dmu.Unlock();
+				return 0;
+			}
+		}
+		IDList.push_back(id);
+		dmu.Unlock();
+	}
+	else
+	{
+		
+		dmu.Lock();
+		if(IDList.empty())
+		{
+			dmu.Unlock();
+			return 0;
+		}
+		iti = IDList.begin();
+		DWORD iID = *iti;
+		IDList.pop_front();
+		dmu.Unlock();
+		return iID;
+	}
+	return 0;
+}
+
+int CAdminServer::rclClientGetGroupInfo(CRCLClientGetCroupInfo *pMSG, SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+
+	int ClassCount = 1;
+	CRCLUserClassInfo ucInfo[10];
+	memset(ucInfo,0,sizeof(ucInfo));
+	
+	rclUserList::iterator itu;
+	umu.Lock();
+
+	for(itu = UserList.begin();itu != UserList.end();++itu)
+	{
+		if((*itu)->rclClientID == pMSG->ClientID)
+		{
+			umu.Unlock();
+			sprintf(textbuf,pstu_get_classinfo,(*itu)->rclName);  
+	
+			
+			printf("here\n");
+			rclRoomList::iterator itr;
+			CRCLMSG response;
+			CRCLClientGetCroupInfoR res;
+			res.GroupCount = 0;
+			res.ResponseType = 0;
+	
+			
+			
+			for(int j=0;j<ClassCount;j++)
+			{
+				rmu.Lock();
+
+				for(itr = RoomList.begin();itr != RoomList.end();++itr)
+				{
+					printf("%s\n",(*itr)->rclName);
+
+					if((*itr)->rclName)
+					{
+						
+						memcpy(res.GroupList[res.GroupCount].GroupName,(*itr)->rclName,128);
+						res.GroupList[res.GroupCount].GroupID = (*itr)->rclRoomID;
+			            printf("get group name\n");
+						
+						rclTeacherList::iterator itt;
+						tmu.Lock();
+
+						for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+						{
+							if((*itt)->rclTeacherID == (*itr)->rclTeacherID)
+							{
+								
+								memcpy(res.GroupList[res.GroupCount].TeacherName,(*itt)->rclName,NAMELEN);//06.10.11
+			                    printf("get teacher info\n");
+								res.GroupCount++;
+			
+								tmu.Unlock();
+								break;
+							}
+						}
+						if(itt == TeacherList.end())
+						{
+							
+							printf("error, no teacher");
+							tmu.Unlock();
+							rmu.Unlock();
+							rclResponseError(10051,s,RCL_STUDENT_GET_GROUPLIST_FAIL);
+							return 1;
+						}
+					}
+					break;
+				}
+				if(itr == RoomList.end())
+				{
+					printf("no class\n");
+					rmu.Unlock();
+					rclResponseError(10051,s,RCL_STUDENT_GET_GROUPLIST_FAIL);
+					return 1;
+				}
+				rmu.Unlock();
+			}
+	
+
+			
+		
+			DWORD i = 0;
+			if(ClassCount == 0)
+			{
+				printf("no class\n");
+				rmu.Lock();
+				res.GroupCount = RoomList.size();
+				rclRoomList::iterator it;
+				
+				for(it=RoomList.begin();it!=RoomList.end();++it)
+				{
+					
+					res.GroupList[i].GroupID = (*it)->rclRoomID;
+					
+					memcpy(res.GroupList[i].GroupName,(*it)->rclName,128);
+			
+					
+					rclTeacherList::iterator itt;
+					tmu.Lock();
+					DWORD TeacherID = (*it)->rclTeacherID;
+
+					for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+					{
+						if((*itt)->rclTeacherID == TeacherID)
+						{
+							memcpy(res.GroupList[i].TeacherName,(*itt)->rclName,NAMELEN);//06.10.11
+							tmu.Unlock();
+							i++;
+							break;
+						}
+					}
+					if(itt == TeacherList.end())
+					{
+						printf("error\n");
+						tmu.Unlock();
+						rmu.Unlock();
+						rclResponseError(10051,s,RCL_STUDENT_GET_GROUPLIST_FAIL);
+						return 1;
+					}
+			
+				}
+				res.ResponseType = 0;
+				rmu.Unlock();
+			}
+	
+			response.rclType = 10051;
+			res.TalkMode = ClientTalk;
+			response.msglen = sizeof(CRCLClientGetCroupInfoR);
+			rclMakePacket(response.msg,(char*)&res,response.msglen);
+			printf("client get group info,send info succeed\n");
+			printf("%d\n",res.ResponseType);
+			rclSendResponse((char*)&response,response.msglen+8,&s,1);
+                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+                        //							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+				
+			return 0;
+		}
+	}
+	if(itu == UserList.end())
+	{
+		printf("error ,no client\n");
+		rclResponseError(10051,s,RCL_STUDENT_GET_GROUPLIST_FAIL);
+		umu.Unlock();
+		return 1;
+	}	
+}
+
+int CAdminServer::rclClientGetClientInfo(CRCLClientGetClientInfo *pMSG, SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+	
+	printf("client get client list\n");
+	printf("%d\n",pMSG->GroupID);
+	CRCLMSG response;
+	CRCLClientGetClientInfoR res;
+	DWORD i = 0;
+
+	rclRoomList::iterator itr;
+	rmu.Lock();
+
+	for(itr = RoomList.begin();itr != RoomList.end();++itr)
+	{
+		if((*itr)->rclRoomID == pMSG->GroupID)
+		{
+			
+			std::list<DWORD>::iterator itc;
+			(*itr)->cs.Lock();
+			for(itc=(*itr)->rclUserRoom.begin();itc!=(*itr)->rclUserRoom.end();++itc)
+			{
+				
+				rclUserList::iterator itu;
+
+				for(itu = UserList.begin();itu != UserList.end();++itu)
+				{
+					if((*itu)->rclClientID == *itc)
+					{
+						sprintf(textbuf,pstu_get_stulist,(*itu)->rclName);  
+						
+						memcpy(res.ClientList[i].ClienName,(*itu)->rclName,NAMELEN);//06.10.11
+						res.ClientList[i].ClientID = (*itu)->rclClientID;
+						res.ClientList[i].IsFocus = 1;
+
+						
+						if((*itu)->rclClientID == (*itr)->rclFocusUserID)
+						{
+							
+							res.ClientList[i].IsFocus = 0;
+						}
+		
+						i++;
+					}
+				}
+				
+			}
+			res.ClientCount = i;
+			res.ResponseType = 0;
+			(*itr)->cs.Unlock();
+			rmu.Unlock();
+
+			
+			response.rclType = 1041;
+			response.msglen = sizeof(CRCLClientGetClientInfoR) - (1024 - res.ClientCount)*sizeof(CClientInfo);
+			rclMakePacket(response.msg,(char*)&res,response.msglen);
+
+			rclSendResponse((char*)&response,response.msglen+8,&s,1);
+                        //			gtk_text_buffer_insert(buffer,&end,textbuf,-1);
+                        //							gtk_text_buffer_insert(buffer,&end,"\n",-1);
+			return 0;
+		}
+	}
+	if(itr == RoomList.end())
+	{
+		printf("can't find room\n");
+		rmu.Unlock();
+		rclResponseError(1041,s,RCL_STUDENT_GET_CLIENTLIST_FAIL);
+		return 1;
+	}	
+}
+
+void CAdminServer::rclResponseInfo(char *info)
+{
+	
+}
+
+
+int CAdminServer::rclTeacherAllowClientFocus(CRCLTeacherAllowClientFocus *pMSG,SOCKET s)
+{
+	char textbuf[TEXTBUFFERLEN];
+	char teacherbuf[20];
+	rclTeacherList::iterator itt;
+	tmu.Lock();
+	for(itt = TeacherList.begin();itt != TeacherList.end();++itt)
+	{
+		if((*itt)->rclTeacherID == pMSG->TeacherID)
+		{
+			strcpy(teacherbuf,(*itt)->rclName);
+		}
+	}
+	tmu.Unlock();
+	
+	rclRoomList::iterator itr;
+	rmu.Lock();
+
+	for(itr = RoomList.begin();itr != RoomList.end();++itr)
+	{
+		if((*itr)->rclRoomID == pMSG->GroupID)
+		{
+			
+			if((*itr)->rclFocusUserID)
+			{
+				
+				rmu.Unlock();
+				rclResponseError(1051,s,RCL_TEACHER_ALLOW_FOCUS_EXIST);
+				return 1;
+			}
+
+			
+			if((*itr)->rclTeacherID != pMSG->TeacherID)
+			{
+				
+				rmu.Unlock();
+				rclResponseError(1051,s,RCL_TEACHER_ALLOW_FOCUS_EXIST);
+				return 1;
+			}
+
+			
+			SOCKET sk[2];
+			mmu.Lock();
+			rclMCUList::iterator itm;
+
+			for(itm = MCUList.begin();itm != MCUList.end();++itm)
+			{
+				if((*itm)->rclMCUID == (*itr)->rclMCUID)
+				{
+					sk[0] = (*itm)->s;
+					mmu.Unlock();
+					
+					umu.Lock();
+					rclUserList::iterator itu;
+
+					for(itu = UserList.begin();itu != UserList.end();++itu)
+					{
+						if((*itu)->rclClientID == pMSG->ClientID)
+						{
+							sprintf(textbuf,pteacher_option_rstu,teacherbuf,(*itu)->rclName); 

[... 2083 lines stripped ...]