예제 #1
0
    void setUIText(ChangeStat stat)
    {
        switch (stat)
        {
        case ChangeStat.health:
        {
            healthText.text = Mathf.CeilToInt(health).ToString();
            break;
        }

        case ChangeStat.armor:
        {
            armorText.text = armor.ToString();
            break;
        }
        }
    }
예제 #2
0
        /// <summary>
        /// 파일 수신 전용 메소드
        /// </summary>
        /// <param name="obj">파일 수신에 필요한 파일 정보(파일이름, 크기, 보낸사람, 보낸사람 id</param>
        private void FileReceiver(object obj)
        {
            try
            {
                Hashtable fileinfo = (Hashtable)obj;
                string filename = null;
                int filesize = 0;
                string sendername = null;
                string senderid = null;
                string fileseq = null;
                int rowIndex = 0;
                string NRseq = null;

                foreach (DictionaryEntry de in fileinfo)
                {
                    if (de.Key.ToString().Equals("name"))
                    {
                        sendername = de.Value.ToString();
                        logWrite("File sender name : " + sendername);
                    }
                    else if (de.Key.ToString().Equals("senderid"))
                    {
                        senderid = de.Value.ToString();
                        logWrite("File sender id : " + senderid);
                    }
                    else if (de.Key.Equals("filenum"))
                    {
                        fileseq = de.Value.ToString();
                    }
                    else if (de.Key.Equals("rowindex"))
                    {
                        rowIndex = Convert.ToInt32(de.Value);
                    }
                    else if (de.Key.Equals("NRseq"))
                    {
                        NRseq = de.Value.ToString();
                    }
                    else if (de.Key.Equals("filename"))
                    {
                        filename = (string)de.Value;
                        logWrite("FileReceiver() : filename=" + filename);
                    }
                    else if (de.Key.Equals("filesize"))
                    {
                        filesize = (int)de.Value;
                        logWrite("FileReceiver() : filesize=" + filesize);
                    }
                }
                #region 파일중복체크/막음
                //FileInfo fi = new FileInfo(filename);
                //int filenum = 0;
                //int strlength = filename.Length;
                //string ext = fi.Extension;

                ////저장할 파일과 같은 이름의 파일이 존재할 경우 처리로직
                //if (fi.Exists == true)
                //{
                //    string str = filename.Substring(0, (strlength - 4));
                //    string tempname = null;
                //    do
                //    {
                //        filenum++;
                //        str += "(" + filenum.ToString() + ")"; //같은 이름의 파일이 있을 경우 "파일명(filenum).확장자" 의 형태로 저장
                //        tempname = str + ext;
                //        fi = new FileInfo(tempname);
                //    } while (fi.Exists == true);
                //    filename = tempname;
                //}
                #endregion
                logWrite("CHOI_DEBUG FileReceiver 1");//CHOI_DEBUG
                if (fileseq == null) //서버수신이 아니고 직접수신인 경우
                {
                    FILE_TCPReceive(filename);
                    logWrite("CHOI_DEBUG FileReceiver 2");//CHOI_DEBUG
                    return;
                }
                logWrite("CHOI_DEBUG FileReceiver 3");//CHOI_DEBUG
            
#region //File UDP Receive
                /*****************************************************************************************************************************
                *****************************************************************************************************************************
                ******************* File UDP Receive********************************************************************************************
                *****************************************************************************************************************************
                * 1. run Listener : file name , size, listen port
                * 2. set event listener
                * 3. progress bar setting
                *****************************************************************************************************************************
                */
                int receivefailcount = 0;
                int sendfailcount = 0;
                byte[] buffer = null;

                FileStream fs = new FileStream(filename, FileMode.Append, FileAccess.Write, FileShare.Read, 40960); //한번에 40960 바이트씩 수신

                if (filesock == null || filesock.Client == null)
                {
                    filesender = new IPEndPoint(IPAddress.Any, filereceiveport);
                    filesock = new UdpClient(filesender);
                }

                filesock.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 5000);

                try
                {
                    lock (filesock)
                    {
                        while (true)
                        {
                            Thread.Sleep(10);
                            //logWrite("FileReceiver() 수신대기 ");
                            try
                            {
                                buffer = filesock.Receive(ref filesender);
                                //logWrite("수신!");
                            }
                            catch (Exception se)
                            {
                                logWrite("FileReceiver()  filesock.Receive 에러 : " + se.ToString());
                                receivefailcount++;
                                if (receivefailcount == 5)
                                {
                                    logWrite("수신 실패 5회로 FileReceiver 중단!");
                                    break;
                                }
                            }
                            if (buffer != null && buffer.Length != 0)
                            {
                                //logWrite("sender IP : " + filesender.Address.ToString());
                                //logWrite("sender port : " + filesender.Port.ToString());

                                byte[] receivebyte = Encoding.UTF8.GetBytes(buffer.Length.ToString());

                                try
                                {
                                    filesock.Send(receivebyte, receivebyte.Length, filesender);  //정상적으로 메시지 수신하면 응답(udp통신의 실패방지)

                                    //logWrite(buffer.Length.ToString() + " byte 수신!");
                                }
                                catch (Exception se1)
                                {
                                    logWrite("FileReceiver() filesock.Send 에러 : " + se1.ToString());
                                    sendfailcount++;
                                    if (sendfailcount == 5)
                                    {
                                        logWrite("응답전송 실패 5회로 FileReceiver 중단!");
                                        break;
                                    }
                                }
                                if (fs.CanWrite == true)
                                {
                                    try
                                    {
                                        fs.Write(buffer, 0, buffer.Length);
                                        fs.Flush();
                                    }
                                    catch (Exception e)
                                    {
                                        logWrite("FileStream.Write() 에러 : " + e.ToString());
                                    }
                                }
                                FileInfo finfo = new FileInfo(filename);

                                int size = Convert.ToInt32(finfo.Length);

                                if (size > 0)
                                {
                                    if (NRseq == null) NRseq = "0";
                                    SendMsg("14|" + NRseq, server);
                                    intParamDele intdele = new intParamDele(refreshNRfile);
                                    Invoke(intdele, rowIndex);

                                }

                                if (size >= filesize)  //파일 데이터를 모두 수신했는지 체크
                                {
                                    if (filesender.Address.Equals(server.Address))
                                    {
                                        ChangeStat showdownloadform = new ChangeStat(ShowDownloadForm); //다운로드 상태바 표시 delegate
                                        Invoke(showdownloadform, new object[] { "서버로 부터", filename });
                                    }
                                    else
                                    {
                                        foreach (DictionaryEntry de in InList)
                                        {
                                            if (((IPEndPoint)de.Value).Address.Equals(filesender.Address))
                                            {
                                                senderid = de.Key.ToString();
                                                logWrite(senderid);
                                                sendername = GetUserName(senderid);
                                                break;
                                            }
                                        }
                                        logWrite("파일 전송 완료");

                                        ChangeStat showdownloadform = new ChangeStat(ShowDownloadForm);
                                        if (senderid.Length > 1)
                                        {
                                            Invoke(showdownloadform, new object[] { sendername + "(" + senderid + ") 님으로 부터", filename });
                                        }
                                        else
                                        {
                                            Invoke(showdownloadform, new object[] { "서버로 부터", filename });
                                        }
                                    }
                                    fs.Close();
                                    break;
                                }
                            }
                        }
                    }
                }
                catch (SocketException e)
                {
                    logWrite("FileReceive() 에러 : " + e.ToString());
                }
                logWrite("FileReceiver 가 중단되었습니다. ");
#endregion //File UDP Send

           }
            catch (Exception exception)
            {
                logWrite(exception.ToString());
            }
        }
예제 #3
0
        /// <summary>
        /// 수신된 메시지를 분석하여 각 요청에 맞게 처리
        /// </summary>
        /// <param name="obj">ArrayList로 형변환할 Object</param>
        protected void MsgFilter(object obj, IPEndPoint iep)
        {
            try
            {
                string msg = ((string)obj).Trim(); //수신 메시지
                string tempFormKey;
                string[] tempMsg = msg.Split('|');
                string code = tempMsg[0];

                switch (code)
                {
#region //일반메신저기능

                    case "f"://로그인 실패시(f|n or p)
                        try
                        {
                            FormTextCtrlDelegate informationMsg = new FormTextCtrlDelegate(ShowMessageBox);
                            if (tempMsg[1].Equals("n"))
                            {
                                Invoke(informationMsg, "등록되지 않은 사용자 입니다.");
                            }
                            else
                                Invoke(informationMsg, "비밀번호가 틀렸습니다.");

                            Loginfail fail = new Loginfail(logInFail);
                            Invoke(fail, null);
                        }
                        catch (Exception e) { };
                        break;

                    case "g": //로그인 성공시 (g|name|team|company|com_cd)
                        
                        connected = true;

                        stringDele changeProgressStyle = new stringDele(chageProgressbar);
                        Invoke(changeProgressStyle, "로딩중");

                        //MiniCTI config 파일 설정
                        FileInfo tempfileinfo = new FileInfo(XmlConfigFullPath);//"C:\\MiniCTI\\config\\MiniCTI_config_demo.xml");
                        if (!tempfileinfo.Exists)
                        {
                            logWrite("MiniCTI config 파일 없음");
                            FileInfo temp = new FileInfo(XmlConfigOrgFullPath);//Application.StartupPath + "\\MiniCTI_config_demo.xml");
                            temp.CopyTo(tempfileinfo.FullName);
                        }
                        setCRM_DB_HOST(XmlConfigFullPath, serverIP);//"c:\\MiniCTI\\config\\MiniCTI_config_demo.xml", serverIP);

                        //서버측에서 전달된 이름 저장
                        myname = tempMsg[1];
                        myid = this.id.Text;
                        com_cd = tempMsg[4];
                        logWrite("로그인 성공! (" + DateTime.Now.ToString() + ")");

                       
                        //개인 정보를 Client_Form 에 표시
                        FormTextCtrlDelegate FlushName = new FormTextCtrlDelegate(FlushInfo);
                        FormTextCtrlDelegate FlushTeam = new FormTextCtrlDelegate(Flushteam);
                        
                        Invoke(FlushName, tempMsg[1]);

                        if (tempMsg[2].Length > 0) {
                            Invoke(FlushTeam, tempMsg[2]);
                        } else {
                            Invoke(FlushTeam, tempMsg[3]);
                        }

                        //화면의 모든 콘트롤에 keydown이벤트설정
                        this.KeyDown += new KeyEventHandler(Client_Form_KeyDown);
                        int count = this.Controls.Count;

                        for (int i = 0; i < count; i++) {
                            this.Controls[i].KeyDown += new KeyEventHandler(Client_Form_KeyDown);
                        }

                        //쪽지 및 대화 저장 폴더, 파일 생성
                        MemoUtils.MemoFileCheck(this.myid);
                        DialogFileCheck();
                        FileDirCheck();

                        if (checkThread == null) {
                            checkThread = new Thread(new ThreadStart(SendCheck));
                            checkThread.Start();
                            logWrite("SendCheck 스레드 시작");
                        }

                        break;


                    case "M": //다른 클라이언트 목록 및 접속상태 정보(M|팀이름|id!멤버이름|id!멤버이름)


                        if (tempMsg[1].Equals("e")) { //모든 팀트리 정보 전송완료 메시지일 경우 -> Client_Form을 로그인 상태로 하위 구성요소를 활성화 한다.
                        
                            PanelCtrlDelegate loginPanel = new PanelCtrlDelegate(LogInPanelVisible); //로그인 패널 컨트롤 호출용
                            PanelCtrlDelegate TreeViewPanel = new PanelCtrlDelegate(TreeViewVisible);  //memTreeView 컨트롤호출용
                            PanelCtrlDelegate btnCtrl = new PanelCtrlDelegate(ButtonCtrl);//각종 버튼 컨트롤호출용
                            
                            Invoke(TreeViewPanel, true);
                            
                            // 버튼 활성화
                            Invoke(btnCtrl, true);

                            //tooltip 설정
                            tooltip.AutoPopDelay = 0;
                            tooltip.AutomaticDelay = 2000;
                            tooltip.InitialDelay = 100;

                            Invoke(loginPanel, false);

                            //crm 프로그램 실행
                            Thread thread = new Thread(new ThreadStart(SetUserInfo));
                            thread.Start();
                            //NoParamDele dele = new NoParamDele(SetUserInfo);
                            //Invoke(dele);
                        } else { // 팀트리 정보를 수신한 경우
                        
                            ArrayList list = new ArrayList();
                            if (tempMsg.Length > 2) {
                                string teamName = tempMsg[1];

                                for (int i = 2; i < tempMsg.Length; i++) {//배열 순서 2번째 부터인 id!name을 추출
                                
                                    if (tempMsg[i].Length != 0) {
                                    
                                        list.Add(tempMsg[i]);
                                        string[] memInfo = tempMsg[i].Split('!');  //<id>와 <name>을 분리하여 memInfo에 저장
                                        MemberInfoList[memInfo[0]] = memInfo[1];    //key=id, value=name
                                        logWrite("MemberInfoList[" + memInfo[0] + "] = " + memInfo[1]);

                                        //다른 상담원의 <소속>과 <id>를 hashtable에 저장(key=id, value=소속)
                                        if (teamName.Trim() == "") { //소속이 미지정인 경우
                                            teamName = MsgrMsg.UNDEFINED_TEAM;
                                        }
                                        TeamInfoList[memInfo[0]] = teamName;
                                        logWrite("TeamInfoList[" + memInfo[0] + "] = " + teamName);
                                        //logWrite("사용자 정보 등록 : 이름(" + memInfo[1] + ") 아이디(" + memInfo[0] + ")");
                                    }
                                }
                                ChildNodeDelegate AddMemNode = new ChildNodeDelegate(MakeMemTree);
                                object[] ar = { teamName, list };
                                Invoke(AddMemNode, ar);

                                treesource[teamName] = list;
                                memTree.Tag = treesource;
                                logWrite(teamName + " 팀 리스트 생성!");

                                //델리게이트 생성
                            }
                        }
                        break;

                    case "y":    //로그인 Client 리스트 y|id|상태값 
                        string team = (string)TeamInfoList[tempMsg[1]];

                        int Port = 8883;
                        logWrite("팀 : "+team+" 사용자 id : " + tempMsg[1] + "  port : " + Port.ToString());

                        //InList[tempMsg[1]] = server;   //로그인 리스트 테이블에 저장(key=id, value=IPEndPoint)

                        ChangeStat changelogin = new ChangeStat(ChangeMemStat);
                        Invoke(changelogin, new object[] { tempMsg[1], tempMsg[2] });

                        break;

                    case "IP":    //로그인 Client 리스트 IP|id|ip주소 

                        Port = 8883;
                        logWrite(" 사용자 id : " + tempMsg[1] + "IP 주소 : " + tempMsg[2] + "  port : " + Port.ToString());

                        InList[tempMsg[1]] = new IPEndPoint(IPAddress.Parse(tempMsg[2]), Port);   //로그인 리스트 테이블에 저장(key=id, value=IPEndPoint)

                        break;

                    case "a":  //중복로그인 시도를 알려줌
                        Loginfail relogin = new Loginfail(ReLogin);
                        Invoke(relogin, null);

                        break;

                    case "u": //서버측에서 강제 로그아웃 메시지 수신한 경우
                        LogOutDelegate logoutDel = new LogOutDelegate(LogOut);
                        Invoke(logoutDel, null);
                        break;

                    case "d":  //상대방 대화메시지일 경우 (d|Formkey|id/id/...|name|메시지)
                        tempFormKey = ChatUtils.GetFormKey(tempMsg[1], myid);

                        string[] ids = tempMsg[2].Split('/');
                        if (!ids[0].Equals(myid)) {
                        
                            if (ChatFormList.Contains((string)tempFormKey) && ChatFormList[(string)tempFormKey] != null) { //이미 발신자와 채팅중일 경우
                            
                                ChatForm form = (ChatForm)ChatFormList[(string)tempFormKey];
                                AddChatMsgDelegate addMsg = new AddChatMsgDelegate(form.PostUserMessage);
                                Invoke(addMsg, new object[] { ids[0], tempMsg[3], tempMsg[4] });//id/id... 첫번째가 문자올린 대화자
                                //if() 사용자 상태에 따라
                                //form.Activate();
                            }
                            else {  //새로운 대화요청일 경우, 대화창 생성
                                ArrangeCtrlDelegate OpenChatForm = new ArrangeCtrlDelegate(NewChatForm);
                                Invoke(OpenChatForm, new object[] { tempMsg });
                            }
                        }
                        break;

                    case "c":  //c|formkey|id/id/..|name  //대화중 초대가 일어난 경우
                        {
                            tempFormKey = ChatUtils.GetFormKey(tempMsg[1], myid);

                            ChatForm form = (ChatForm)ChatFormList[(string)tempFormKey];

                            if (form != null) {

                                string[] addedIdArray = tempMsg[2].Split('/');
                                AddChatterDelegate addChatter = new AddChatterDelegate(form.AddChatterToNode);

                                foreach (string addedId in addedIdArray) {
                                    UserObject userObj = ChatUtils.FindUserObjectTagFromTreeNodes(memTree.Nodes, addedId);
                                    Invoke(addChatter, new object[] { userObj });
                                }

                                string newFormKey = ChatUtils.GetFormKeyWithMultiUsersAdded(tempFormKey, myid, tempMsg[2]);
                                SetChatFormKeyUpdate(form, newFormKey, tempFormKey);
                            
                            } else {
                                logWrite(string.Format("'c' key[{0}]를 갖는 채팅창이 존재하지 않음.", tempFormKey));
                            }
                        }
                        break;

                    case "C":  //보낸공지 읽음확인 수신(C|확인자id|noticeid)
                        ArrangeCtrlDelegate NoticeDetailResultFormAdd = new ArrangeCtrlDelegate(NoticeReaderAdd);
                        Invoke(NoticeDetailResultFormAdd, new object[] { tempMsg });
                        break;

                    case "q": //다자 대화중 상대방이 대화창 나감 (q|Formkey|id)
                        {
                            tempFormKey = ChatUtils.GetFormKey(tempMsg[1], myid);

                            ChatForm form = (ChatForm)ChatFormList[(string)tempFormKey];
                            if (form != null)
                            {
                                //노드삭제
                                DelChatterDelegate delchatter = new DelChatterDelegate(form.DeleteChatter);
                                Invoke(delchatter, new object[] { tempMsg[2], GetUserName(tempMsg[2]) });
                                //formkey 변경
                                string newFormKey = ChatUtils.GetFormKeyWithUserQuit(tempFormKey, myid, tempMsg[2]);
                                SetChatFormKeyUpdate(form, newFormKey, tempFormKey);
                            }
                            else
                            {
                                logWrite(string.Format("'q' key[{0}]를 갖는 채팅창이 존재하지 않음.", tempFormKey));
                            }
                        }
                        break;

                    case "dc": //다자 대화중 상대방이 연결 끊김 (dc|Formkey|id)
                        {
                            tempFormKey = ChatUtils.GetFormKey(tempMsg[1], myid);

                            ChatForm form = (ChatForm)ChatFormList[(string)tempFormKey];
                            if (form != null)
                            {
                                //노드삭제
                                DelChatterDelegate delchatter = new DelChatterDelegate(form.DeleteChatter);
                                Invoke(delchatter, new object[] { tempMsg[2], GetUserName(tempMsg[2]) });
                                //formkey 변경
                                string newFormKey = ChatUtils.GetFormKeyWithUserQuit(tempFormKey, myid, tempMsg[2]);
                                SetChatFormKeyUpdate(form, newFormKey, tempFormKey);
                            }
                            else
                            {
                                logWrite(string.Format("'dc' key[{0}]를 갖는 채팅창이 존재하지 않음.", tempFormKey));
                            }
                        }
                        break;

                    case "m"://메모를 수신한 경우 m|name|id|message|수신자id
                        ArrangeCtrlDelegate memo = new ArrangeCtrlDelegate(MakeMemo);
                        Invoke(memo, new object[] { tempMsg });
                        MemoUtils.MemoFileWrite(this.myid, msg + "|" + DateTime.Now.ToString());
                        break;
#endregion //일반메신저기능

                    case "F":  //파일받기전 파일 정보 수신     F|파일명|파일크기|파일key|전송자id
                        string name = GetUserName(tempMsg[4]);
                        string[] filenameArray = tempMsg[1].Split('\\'); //파일명 추출
                        int filesize = int.Parse(tempMsg[2]);            //파일크기 캐스팅
                        IPEndPoint siep = (IPEndPoint)InList[tempMsg[4]];
                        siep.Port = 8883;
                        string savefilename = "C:\\MiniCTI\\" + this.myid + "\\Files\\" + filenameArray[filenameArray.Length - 1];

                        //수락여부 확인 플로우로 넘김
                        //1.수락
                        //      FTP_ShowDialog(Hashtable info);
                        //                 form.ShowDialog(Hashtable info);
                        //          event FTP_DialogResultReceived(CustomEvent);
                        //2-1.거부
                        //2-2.종료
                        //          event FTP_OnStatusChanged
                        //                  
                        //2.수락메시지전송
                        //      
                        //3.수신대기 
                        //      FileReceiver
                        //4.수신
                        //      FTP_ShowStatus(Receive|Cancel|Done|Error)
                        //              form.ShowStatus(Hashtable info);
                        //5.완료
                        //      FTP_StopReceiving()
                        //6.취소
                        //      FTP_CancelReceiving()
                        //7.실패
                        //      
                        if (InList.ContainsKey(tempMsg[4]) && InList[tempMsg[4]] != null) //전송대상자가 로그인 상태인 경우
                        {
                            //Hashtable info = new Hashtable();
                            //info["filename"] = savefilename;
                            //info["filesize"] = filesize;
                            //info["name"] = name;
                            //info["senderid"] = tempMsg[4];
                            //info["myid"] = myid;
                            DownloadInfo info = new DownloadInfo();
                            info.FileName = savefilename;
                            info.FileSize = filesize;
                            info.SenderName = name;
                            info.SenderId = tempMsg[4];
                            info.MyId = myid;
                            info.MsgFileKey = tempMsg[3];
                            info.SenderFileName = tempMsg[1];
                            if (mDownloadPath != null && mDownloadPath.Trim() != "")
                                info.DownloadPath = mDownloadPath;
                            else
                                info.DownloadPath = string.Format(@"C:\MiniCTI\{0}\Files", myid);
                            //FTP_ShowDialg(info);
                            FTP_ShowDialogDelegate delShow = new FTP_ShowDialogDelegate(FTP_ShowDialg);
                            Invoke(delShow, new object[] { info });

                        }
                        break;
                        #region 파일로직변경으로 막음
                        //if (InList.ContainsKey(tempMsg[4]) && InList[tempMsg[4]] != null) //전송대상자가 로그인 상태인 경우
                        //{
                        //    Hashtable info = new Hashtable();
                        //    info[savefilename] = filesize;
                        //    info["name"] = name;
                        //    info["senderid"] = tempMsg[4];

                        //    //파일받기 수락 메시지전송
                        //    SendMsg("Y|" + tempMsg[1] + "|" + tempMsg[3] + "|" + this.myid, siep); //구성(Y|파일명|파일Key|수신자id)

                        //    //파일수신대기/수신
                        //    FileReceiver((object)info);
                        //}
                        
                        //downloadform.Show();
                        
                        //break;
                        #endregion
                    case "Y"://파일 받기 수락 메시지(Y|파일명|파일key|수신자id)
                        ShowFileSendDetailDelegate show = new ShowFileSendDetailDelegate(ShowFileSendDetail);
                        Hashtable table = new Hashtable();
                        table[tempMsg] = (IPEndPoint)InList[tempMsg[3]];

                        //파일 전송 스레드 시작
                        Thread sendfile = new Thread(new ParameterizedThreadStart(SendFile));
                        sendfile.Start((object)table);

                        FileSendThreadList[tempMsg[2] + "|" + tempMsg[3]] = sendfile;

                        FileSendDetailListView view = (FileSendDetailListView)FileSendDetailList[tempMsg[2]];
                        Invoke(show, new object[] { tempMsg[3], "전송대기중", view });

                        break;

                    case "FS"://파일 받기 수락 메시지(FS|파일명|파일key|수신자id)
                        ShowFileSendDetailDelegate show_ = new ShowFileSendDetailDelegate(ShowFileSendDetail);
                        Hashtable table_ = new Hashtable();
                        table_[tempMsg] = server;

                        //파일 전송 스레드 시작
                        Thread sendfile_ = new Thread(new ParameterizedThreadStart(SendFile));
                        sendfile_.Start((object)table_);

                        FileSendThreadList[tempMsg[2] + "|" + tempMsg[3]] = sendfile_;

                        FileSendDetailListView view_ = (FileSendDetailListView)FileSendDetailList[tempMsg[2]];
                        Invoke(show_, new object[] { tempMsg[3], "전송대기중", view_ });

                        break;

                    case "N": //파일 받기 거부("N|파일명|파일키|id)

                        ShowFileSendDetailDelegate detail = new ShowFileSendDetailDelegate(ShowFileSendDetail);

                        FileSendDetailListView View = (FileSendDetailListView)FileSendDetailList[tempMsg[2]];

                        Invoke(detail, new object[] { tempMsg[3], "받기 거부", View });

                        string Name = GetUserName(tempMsg[3]);
                        string[] FilenameArray = tempMsg[1].Split('\\');
                        MessageBox.Show(Name + " 님이 파일 받기를 거부하셨습니다.\r\n\r\n파일명 : " + FilenameArray[(FilenameArray.Length - 1)], "알림", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        break;
                    #region //일반 메신저기능
                    case "i":  //추가 로그인 상담원일 경우  형태 : i|id|소속팀명|ip|이름

                        try {
                            //1. 로그인 리스트 테이블에 추가
                            IPEndPoint addiep = new IPEndPoint(IPAddress.Parse(tempMsg[3]), 8883);
                            InList[tempMsg[1]] = addiep;

                            //2. memTree 뷰에 로그인 사용자 상태 변경
                            ChangeStat change = new ChangeStat(ChangeMemStat);
                            Invoke(change, new object[] { tempMsg[1], "online" });
                            TeamInfoList[tempMsg[1]] = tempMsg[2];
                            
                            //3. 각 채팅창 key변경 및 채팅창 노드/상태변경
                            ChangeStat logInChatter = new ChangeStat(SetUserStatusInChatForm);
                            Invoke(logInChatter, new object[] { tempMsg[1], MsgrUserStatus.ONLINE });

                            //4. 로그인 했음 메시지 창 띄움
                            // 추후 구현
                        } catch (Exception e) {
                            logWrite(e.ToString());
                        }
                        break;

                    case "o":  //로그아웃 상담원이 발생할 경우  o|id|소속
                        try {
                            //1. 로그인 리스트 테이블에서 삭제
                            lock (this) {
                                InList[tempMsg[1]] = null;
                            }
                            //2. memTree 뷰에 로그아웃 사용자 상태 변경
                            ChangeStat logout = new ChangeStat(ChangeMemStat);
                            Invoke(logout, new object[] { tempMsg[1], tempMsg[2] });

                            //3. 각 채팅창 key변경 및 채팅창 노드/상태변경
                            ChangeStat logOutChatter = new ChangeStat(SetUserStatusInChatForm);
                            Invoke(logOutChatter, new object[] {tempMsg[1], MsgrUserStatus.LOGOUT});
                        } catch (Exception e) {
                            logWrite(e.ToString());
                        }
                        break;

                    case "n":  //공지사항 메시지 (n|메시지|발신자id|mode|noticetime|제목)

                        logWrite("공지사항 수신!");
                        if (!tempMsg[2].Equals(this.myid)) //자기가 보낸 공지일 경우 보이지 않음
                        {
                            ArrangeCtrlDelegate notice = new ArrangeCtrlDelegate(ShowNoticeDirect);
                            Invoke(notice, new object[] { tempMsg });
                        }
                      
                        break;

                    case "A": //부재중 정보 전달(A|mnum|fnum|nnum|tnum)
                        ArrangeCtrlDelegate ShowAbsentInfo = new ArrangeCtrlDelegate(ShowAbsentInfoNumber);
                        Invoke(ShowAbsentInfo, new object[] { tempMsg });
                        
                        break;

                    case "Q"://안읽은 메모 리스트 (Q|sender;content;time;seqnum|sender;content;time;seqnum|...
                        ArrangeCtrlDelegate ShowNRmemoList = new ArrangeCtrlDelegate(ShowMemoList);
                        Invoke(ShowNRmemoList, new object[] { tempMsg });

                        break;

                    case "T"://안읽은 공지 리스트 (T|sender;content;time;mode;seqnum|sender;content;time;mode;seqnum|...
                        ArrangeCtrlDelegate ShowNRnoticeList = new ArrangeCtrlDelegate(ShowNotReadNoticeList);
                        Invoke(ShowNRnoticeList, new object[] { tempMsg });

                        break;

                    case "R"://안읽은 파일 리스트 (R|보낸사람;filenum;filename;time;size;seqnum|보낸사람;filenum;filename;time;size;seqnum|...
                        ArrangeCtrlDelegate ShowNRFileList = new ArrangeCtrlDelegate(ShowFileList);
                        Invoke(ShowNRFileList, new object[] { tempMsg });

                        break;

                    case "t": //"t|ntime†content†nmode†title†안읽은사람1:안읽은사람2:...|...
                        
                        ArrangeCtrlDelegate ShowNoticeResultFromDB = new ArrangeCtrlDelegate(showNoticeResultFromDB);
                        Invoke(ShowNoticeResultFromDB, new object[] { tempMsg });

                        break;

                    case "L"://공지사항 리스트 수신한 경우  L|time!content!mode!sender!seqnum
                        if (!(tempMsg.Length < 2))
                        {
                            ArrangeCtrlDelegate makeNoticeList = new ArrangeCtrlDelegate(MakeNoticeListForm);
                            Invoke(makeNoticeList, new object[] { tempMsg });
                        }
                        else
                        {
                            MessageBox.Show("등록된 공지가 없습니다.", "공지없음", MessageBoxButtons.OK);
                        }
                        break;
                            #endregion //일반 메신저 기능
                    case "s"://각 클라이언트 상태값 변경 메시지 s|id|상태|IPAddress
                        {
                            if (!tempMsg[1].Equals(this.myid))
                            {
                                //1. 트리상태변경 
                                ChangeStat presenceupdate = new ChangeStat(PresenceUpdate);
                                Invoke(presenceupdate, new object[] { tempMsg[1], tempMsg[2] });
                                //2. 로그인리스트 테이블에 추가
                                IPEndPoint tempiep = new IPEndPoint(IPAddress.Parse(tempMsg[3]), listenport);
                                lock (InList)
                                {
                                    InList[tempMsg[1]] = tempiep;
                                }
                                //3. 채팅창 상태변경
                                //   각 채팅창 key변경 및 채팅창 노드/상태변경
                                ChangeStat changeStat = new ChangeStat(SetUserStatusInChatForm);
                                Invoke(changeStat, new object[] { tempMsg[1], tempMsg[2] });
                            }
                        }
                        break;
                    #region //전화기능
                    case "Ring": //발신자 표시(Ring|ani|name|server_type)

                        RingingDele ringdele = new RingingDele(Ringing);
                        Invoke(ringdele, new object[] { tempMsg[1], tempMsg[2], tempMsg[3] });

                        break;

                    case "Dial": //다이얼시 고객정보 팝업(Dial|ani)
                        if (this.nopop_outbound == false)
                        {
                            doublestringDele dialdele = new doublestringDele(Answer);
                            Invoke(dialdele, new object[] { tempMsg[1], "2" });
                        }
                        break;

                    case "Answer": //offhook시 고객정보 팝업(Answer|ani|type)
                        doublestringDele answerdele = new doublestringDele(Answer);
                        Invoke(answerdele, new object[] { tempMsg[1], tempMsg[2] });
                        
                        break;

                    case "Abandon": //Abandon 발생시
                        AbandonDele abandon = new AbandonDele(Abandoned);
                        Invoke(abandon);
                        break;

                    case "Other": //다른사람이 응답시
                        AbandonDele other = new AbandonDele(OtherAnswer);
                        Invoke(other);
                        break;
                    #endregion //전화기능
                    case "pass"://고객정보 전달 수신(pass|ani|senderID|receiverID
                        if (tempMsg[2].Equals(this.myid))
                        {
                            //MessageBox.Show("이관되었습니다.");
                        }
                        else
                        {
                            //notifyTransfer(tempMsg);
                            ArrangeCtrlDelegate passdele = new ArrangeCtrlDelegate(notifyTransfer);
                            Invoke(passdele, new object[]{tempMsg});
                        }
                        break;

                    case "trans"://부재중 이관 메시시 수신(trans|sender†content†time†seqnum|...)
                        ArrangeCtrlDelegate ShowNRTransList = new ArrangeCtrlDelegate(showNoreadTransfer);
                        Invoke(ShowNRTransList, new object[] { tempMsg });
                        break;

                }
            }
            catch (Exception exception)
            {
                logWrite(exception.StackTrace);
            }
        }
예제 #4
0
        //private void Receive()
        //{
        //    receiverStart = true;
        //    byte[] msgbuffer = null;
        //    byte[] header = null;
        //    byte[] buffer = null;
        //    try
        //    {
        //        while (true)
        //        {
        //            if (ServerSocket != null && ServerSocket.Connected)
        //            {
        //                logWrite("�޽��� ����!");
        //                header = new byte[4];
        //                ServerSocket.Receive(header, 4, SocketFlags.Peek);
        //                if (Encoding.ASCII.GetString(header).Trim().Equals("SIZE"))
        //                {
        //                    ServerSocket.Receive(header, 4, SocketFlags.None);
        //                    header = new byte[5];
        //                    ServerSocket.Receive(header, 5, SocketFlags.None);
        //                    string size = Encoding.ASCII.GetString(header);
        //                    logWrite("SIZE : " + size);
        //                    msgbuffer = new byte[Convert.ToInt32(size.Trim())];
        //                    ServerSocket.Receive(msgbuffer, Convert.ToInt32(size.Trim()), SocketFlags.None);
        //                }
        //                if (msgbuffer != null && msgbuffer.Length != 0)
        //                {
        //                    logWrite("sender IP : " + ((IPEndPoint)ServerSocket.RemoteEndPoint).Address.ToString());
        //                    logWrite("sender port : " + ((IPEndPoint)ServerSocket.RemoteEndPoint).Port.ToString());
        //                    string msg = Encoding.UTF8.GetString(msgbuffer);
        //                    logWrite("���� �޽��� : " + msg);
        //                    ArrayList list = new ArrayList();  //MsgFilter �޼ҵ忡 ���� �Ű����� ����
        //                    Thread msgThread = new Thread(new ParameterizedThreadStart(MsgFilter)); //���ŵ� �޽����� ó���� ���� ������ ����
        //                    msgThread.Start(msg);
        //                }
        //            }
        //            else
        //            {
        //                logWrite("ServerSocket is Disconnected");
        //                break;
        //            }
        //        }
        //    }
        //    catch (ThreadAbortException e)
        //    {}
        //    catch(SocketException e)
        //    {
        //        if (connected == true)
        //            logWrite("Receive() ���� : " + e.ToString());
        //    }
        //    if (connected == true)
        //        logWrite("##���## : Receiver �� �ߴܵǾ����ϴ�. ");
        //}
        /// <summary>
        /// ���� ���� ���� �޼ҵ�
        /// </summary>
        /// <param name="obj">���� ���ſ� �ʿ��� ���� ����(�����̸�, ũ��, �������, ������� id</param>
        private void FileReceiver(object obj)
        {
            try
            {
                Hashtable fileinfo = (Hashtable)obj;
                string filename = null;
                int filesize = 0;
                string sendername = null;
                string senderid = null;
                string fileseq = null;
                int rowIndex = 0;
                string NRseq = null;

                foreach (DictionaryEntry de in fileinfo)
                {
                    if (de.Key.ToString().Equals("name"))
                    {
                        sendername = de.Value.ToString();
                        logWrite("File sender name : " + sendername);
                    }
                    else if (de.Key.ToString().Equals("senderid"))
                    {
                        senderid = de.Value.ToString();
                        logWrite("File sender id : " + senderid);
                    }
                    else if (de.Key.Equals("filenum"))
                    {
                        fileseq = de.Value.ToString();
                    }
                    else if (de.Key.Equals("rowindex"))
                    {
                        rowIndex = Convert.ToInt32(de.Value);
                    }
                    else if (de.Key.Equals("NRseq"))
                    {
                        NRseq = de.Value.ToString();
                    }
                    else
                    {
                        filename = (string)de.Key;
                        logWrite("FileReceiver() : filename=" + filename);

                        filesize = (int)de.Value;
                        logWrite("FileReceiver() : filesize=" + filesize);
                    }
                }

                byte[] buffer = null;

                FileInfo fi = new FileInfo(filename);
                int filenum = 0;
                int strlength = filename.Length;
                string ext = fi.Extension;

                //������ ���ϰ� ���� �̸��� ������ ������ ��� ó������
                if (fi.Exists == true)
                {
                    string str = filename.Substring(0, (strlength - 4));
                    string tempname = null;
                    do
                    {
                        filenum++;
                        str += "(" + filenum.ToString() + ")"; //���� �̸��� ������ ���� ��� "���ϸ�(filenum).Ȯ����" �� ���·� ����
                        tempname = str + ext;
                        fi = new FileInfo(tempname);
                    } while (fi.Exists == true);
                    filename = tempname;
                }

                int receivefailcount = 0;
                int sendfailcount = 0;
                FileStream fs = new FileStream(filename, FileMode.Append, FileAccess.Write, FileShare.Read, 40960); //�ѹ��� 40960 ����Ʈ�� ����

                if (filesock == null)
                {
                    filesender = new IPEndPoint(IPAddress.Any, filereceiveport);
                    filesock = new UdpClient(filesender);
                }

                filesock.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveTimeout, 5000);

                try
                {
                    lock (filesock)
                    {
                        while (true)
                        {
                            Thread.Sleep(10);
                            //logWrite("FileReceiver() ���Ŵ�� ");
                            try
                            {
                                buffer = filesock.Receive(ref filesender);
                                //logWrite("����!");
                            }
                            catch (Exception se)
                            {
                                logWrite("FileReceiver()  filesock.Receive ���� : " + se.ToString());
                                receivefailcount++;
                                if (receivefailcount == 5)
                                {
                                    logWrite("���� ���� 5ȸ�� FileReceiver �ߴ�!");
                                    break;
                                }
                            }
                            if (buffer != null && buffer.Length != 0)
                            {
                                //logWrite("sender IP : " + filesender.Address.ToString());
                                //logWrite("sender port : " + filesender.Port.ToString());

                                byte[] receivebyte = Encoding.UTF8.GetBytes(buffer.Length.ToString());

                                try
                                {
                                    filesock.Send(receivebyte, receivebyte.Length, filesender);  //���������� �޽��� �����ϸ� ����(udp����� ���й���)

                                    //logWrite(buffer.Length.ToString() + " byte ����!");
                                }
                                catch (Exception se1)
                                {
                                    logWrite("FileReceiver() filesock.Send ���� : " + se1.ToString());
                                    sendfailcount++;
                                    if (sendfailcount == 5)
                                    {
                                        logWrite("�������� ���� 5ȸ�� FileReceiver �ߴ�!");
                                        break;
                                    }
                                }
                                if (fs.CanWrite == true)
                                {
                                    try
                                    {
                                        fs.Write(buffer, 0, buffer.Length);
                                        fs.Flush();
                                    }
                                    catch (Exception e)
                                    {
                                        logWrite("FileStream.Write() ���� : " + e.ToString());
                                    }
                                }
                                FileInfo finfo = new FileInfo(filename);

                                int size = Convert.ToInt32(finfo.Length);

                                if (size > 0)
                                {
                                    SendMsg("14|" + NRseq, server);
                                    intParamDele intdele = new intParamDele(refreshNRfile);
                                    Invoke(intdele, rowIndex);

                                }

                                if (size >= filesize)  //���� �����͸� ��� �����ߴ��� üũ
                                {
                                    if (filesender.Address.Equals(server.Address))
                                    {
                                        ChangeStat showdownloadform = new ChangeStat(ShowDownloadForm); //�ٿ�ε� ���¹� ǥ�� delegate
                                        Invoke(showdownloadform, new object[] { "������ ����", filename });
                                    }
                                    else
                                    {
                                        foreach (DictionaryEntry de in InList)
                                        {
                                            if (((IPEndPoint)de.Value).Address.Equals(filesender.Address))
                                            {
                                                senderid = de.Key.ToString();
                                                logWrite(senderid);
                                                sendername = getName(senderid);
                                                break;
                                            }
                                        }
                                        logWrite("���� ���� �Ϸ�");

                                        ChangeStat showdownloadform = new ChangeStat(ShowDownloadForm);
                                        if (senderid.Length > 1)
                                        {
                                            Invoke(showdownloadform, new object[] { sendername + "(" + senderid + ") ������ ����", filename });
                                        }
                                        else
                                        {
                                            Invoke(showdownloadform, new object[] { "������ ����", filename });
                                        }
                                    }
                                    fs.Close();
                                    break;
                                }
                            }
                        }
                    }
                }
                catch (SocketException e)
                {
                    logWrite("FileReceive() ���� : " + e.ToString());
                }
                logWrite("FileReceiver �� �ߴܵǾ����ϴ�. ");
            }
            catch (Exception exception)
            {
                logWrite(exception.ToString());
            }
        }
예제 #5
0
        /// <summary>
        /// ���ŵ� �޽����� �м��Ͽ� �� ��û�� �°� ó��
        /// </summary>
        /// <param name="obj">ArrayList�� ����ȯ�� Object</param>
        protected void MsgFilter(object obj, IPEndPoint iep)
        {
            try
            {
                string msg = (string)obj; //���� �޽���
                msg = msg.Trim();

                string[] tempMsg = msg.Split('|');
                string code = tempMsg[0];
                switch (code)
                {
                    case "f"://�α��� ���н�(f|n or p)
                        try
                        {
                            FormTextCtrlDelegate informationMsg = new FormTextCtrlDelegate(ShowMessageBox);
                            if (tempMsg[1].Equals("n"))
                            {
                                Invoke(informationMsg, "��ϵ��� ���� ����� �Դϴ�.");
                            }
                            else
                                Invoke(informationMsg, "��й�ȣ�� Ʋ�Ƚ��ϴ�.");

                            Loginfail fail = new Loginfail(logInFail);
                            Invoke(fail, null);
                        }
                        catch (Exception e) { };
                        break;

                    case "g": //��� ������ (g|name|team|company|com_cd)

                        connected = true;

                        stringDele changeProgressStyle = new stringDele(chageProgressbar);
                        Invoke(changeProgressStyle, "���");
                        setCRM_DB_HOST(XmlConfigOrgFullPath, serverIP);//Application.StartupPath + "\\MiniCTI_config_demo.xml", serverIP);
                        setCRM_DB_HOST(XmlConfigFullPath, serverIP);//"c:\\MiniCTI\\config\\MiniCTI_config_demo.xml", serverIP);

                        FileInfo temp = new FileInfo(XmlConfigOrgFullPath);//Application.StartupPath + "\\MiniCTI_config_demo.xml");

                        FileInfo tempfileinfo = new FileInfo(XmlConfigFullPath);//"C:\\MiniCTI\\config\\MiniCTI_config_demo.xml");
                        if (!tempfileinfo.Exists)
                        {
                            logWrite("MiniCTI config ���� ����");
                            FileInfo file_copied = temp.CopyTo(tempfileinfo.FullName);
                        }
                        else
                        {
                            FileInfo file_copied = temp.CopyTo(tempfileinfo.FullName, true);
                        }

                        myname = tempMsg[1];//���������� ���޵� �̸� ����
                        myid = this.id.Text;
                        com_cd = tempMsg[4];
                        logWrite("��� ����! (" + DateTime.Now.ToString() + ")");

                        //���� ������ Client_Form �� ǥ��
                        FormTextCtrlDelegate FlushName = new FormTextCtrlDelegate(FlushInfo);
                        FormTextCtrlDelegate FlushTeam = new FormTextCtrlDelegate(Flushteam);

                        Invoke(FlushName, tempMsg[1]);

                        if (tempMsg[2].Length > 0)
                        {
                            Invoke(FlushTeam, tempMsg[2]);
                        }
                        else
                        {
                            Invoke(FlushTeam, tempMsg[3]);
                        }

                        this.KeyDown += new KeyEventHandler(Client_Form_KeyDown);
                        int count = this.Controls.Count;

                        for (int i = 0; i < count; i++)
                        {
                            this.Controls[i].KeyDown += new KeyEventHandler(Client_Form_KeyDown);
                        }

                        //���� �� ��ȭ ���� ����, ���� ����
                        MemoFileCheck();
                        DialogFileCheck();
                        FileDirCheck();

                        if (checkThread == null)
                        {
                            checkThread = new Thread(new ThreadStart(SendCheck));
                            checkThread.Start();
                            logWrite("SendCheck ������ ����");
                        }

                        break;

                    case "M": //�ٸ� Ŭ���̾�Ʈ ��� �� ���ӻ��� ����(M|���̸�|id!����̸�|id!����̸�)

                        if (tempMsg[1].Equals("e")) //��� ��Ʈ�� ���� ���ۿϷ� �޽����� ��� -> Client_Form�� �α��� ���·� ���� ������Ҹ� Ȱ��ȭ �Ѵ�.
                        {
                            PanelCtrlDelegate loginPanel = new PanelCtrlDelegate(LogInPanelVisible); //�α��� �г� ��Ʈ�� ȣ���
                            PanelCtrlDelegate TreeViewPanel = new PanelCtrlDelegate(TreeViewVisible);  //memTreeView ��Ʈ��ȣ���
                            PanelCtrlDelegate btnCtrl = new PanelCtrlDelegate(ButtonCtrl);//���� ��ư ��Ʈ��ȣ���

                            Invoke(TreeViewPanel, true);

                            // ��ư Ȱ��ȭ
                            Invoke(btnCtrl, true);

                            //tooltip ����
                            tooltip.AutoPopDelay = 0;
                            tooltip.AutomaticDelay = 2000;
                            tooltip.InitialDelay = 100;

                            Invoke(loginPanel, false);

                            //crm ���α׷� ����
                            Thread thread = new Thread(new ThreadStart(SetUserInfo));
                            thread.Start();
                            //NoParamDele dele = new NoParamDele(SetUserInfo);
                            //Invoke(dele);
                        }
                        else // ��Ʈ�� ������ ������ ���
                        {
                            ArrayList list = new ArrayList();
                            if (tempMsg.Length > 2)
                            {
                                int m = 0;
                                for (int i = 2; i < tempMsg.Length; i++) //�迭 ���� 2��° ������ id!name�� ����
                                {
                                    if (tempMsg[i].Length != 0)
                                    {
                                        list.Add(tempMsg[i]);
                                        string[] memInfo = tempMsg[i].Split('!');  //<id>�� <name>�� �и��Ͽ� memInfo�� ����
                                        MemberInfoList[memInfo[0]] = memInfo[1];
                                        logWrite("MemberInfoList[" + memInfo[0] + "] = " + memInfo[1]);
                                        TeamInfoList[memInfo[0]] = tempMsg[1];      //�ٸ� ������ <�Ҽ�>�� <id>�� hashtable�� ����(key=id, value=�Ҽ�)
                                        logWrite("TeamInfoList[" + memInfo[0] + "] = " + tempMsg[1]);
                                        //logWrite("����� ���� ��� : �̸�(" + memInfo[1] + ") ���̵�(" + memInfo[0] + ")");
                                    }

                                }
                                ChildNodeDelegate AddMemNode = new ChildNodeDelegate(MakeMemTree);
                                object[] ar = { tempMsg[1], list };
                                Invoke(AddMemNode, ar);

                                treesource[tempMsg[1]] = list;
                                memTree.Tag = treesource;
                                logWrite(tempMsg[1] + " �� ����Ʈ ����!");

                                //��������Ʈ ����

                            }
                        }
                        break;

                    case "y":    //�α��� Client ����Ʈ y|id|���°�
                        string team = (string)TeamInfoList[tempMsg[1]];

                        int Port = 8883;
                        logWrite("�� : "+team+ " ����� id : " + tempMsg[1] + "  port : " + Port.ToString());

                        //InList[tempMsg[1]] = server;   //�α��� ����Ʈ ���̺�� ����(key=id, value=IPEndPoint)

                        ChangeStat changelogin = new ChangeStat(ChangeMemStat);
                        Invoke(changelogin, new object[] { tempMsg[1], tempMsg[2] });

                        break;

                    case "IP":    //�α��� Client ����Ʈ IP|id|ip�ּ�

                        Port = 8883;
                        logWrite(" ����� id : " + tempMsg[1] + "IP �ּ� : " + tempMsg[2] + "  port : " + Port.ToString());

                        InList[tempMsg[1]] = new IPEndPoint(IPAddress.Parse(tempMsg[2]), Port);   //�α��� ����Ʈ ���̺�� ����(key=id, value=IPEndPoint)

                        break;

                    case "a":  //�ߺ��α��� �õ��� �˷���
                        Loginfail relogin = new Loginfail(ReLogin);
                        Invoke(relogin, null);

                        break;

                    case "u": //���������� ���� �α׾ƿ� �޽��� ������ ���
                        LogOutDelegate logoutDel = new LogOutDelegate(LogOut);
                        Invoke(logoutDel, null);
                        break;

                    case "d":  //���� ��ȭ�޽����� ��� (d|Formkey|id/id/...|name|�޽���)

                        string[] ids = tempMsg[2].Split('/');
                        if (!ids[0].Equals(myid))
                        {
                            if (ChatFormList.Contains(tempMsg[1]) && ChatFormList[tempMsg[1]] != null)  //�̹� �߽��ڿ� ä������ ���
                            {
                                ChatForm form = (ChatForm)ChatFormList[tempMsg[1]];
                                AddChatMsg addMsg = new AddChatMsg(Addmsg);
                                string smsg = tempMsg[3] + "|" + tempMsg[4];
                                Invoke(addMsg, new object[] { smsg, form });

                                //if() ����� ���¿� ����
                                //form.Activate();
                            }
                            else                                   //���ο� ��ȭ��û�� ���
                            {
                                ArrangeCtrlDelegate OpenChatForm = new ArrangeCtrlDelegate(NewChatForm);
                                Invoke(OpenChatForm, new object[] { tempMsg });
                            }
                        }
                        break;

                    case "c":  //c|formkey|id/id/..|name  //��ȭ�� �ʴ밡 �Ͼ ���

                        if (ChatFormList.ContainsKey(tempMsg[1]) && ChatFormList[tempMsg[1]] != null)
                        {
                            string[] nameArray = tempMsg[2].Split('/');
                            ChatForm form = (ChatForm)ChatFormList[tempMsg[1]];
                            AddChatter addChatter = new AddChatter(Addchatter);
                            AddChatMsg addMsg = new AddChatMsg(Addmsg);

                            for (int i = 0; i < (nameArray.Length - 1); i++)
                            {
                                string tempname = getName(nameArray[i]);
                                Invoke(addChatter, new object[] { nameArray[i], tempname, form });
                                //string tempmsg = tempMsg[3] + "���� " + tempname + "���� ��ȭ�� �ʴ��Ͽ����ϴ�.";
                                //Invoke(addMsg, new object[] { tempmsg, form });
                            }
                        }

                        break;

                    case "C":  //�������� ����Ȯ�� ����(C|Ȯ����id|noticeid)
                        ArrangeCtrlDelegate NoticeDetailResultFormAdd = new ArrangeCtrlDelegate(NoticeReaderAdd);
                        Invoke(NoticeDetailResultFormAdd, new object[] { tempMsg });
                        break;

                    case "q": //���� ��ȭ�� ������ ��ȭâ ���� (q|Formkey|id)

                        if (ChatFormList.ContainsKey(tempMsg[1]) && ChatFormList[tempMsg[1]] != null)
                        {
                            ChatForm form = (ChatForm)ChatFormList[tempMsg[1]];
                            DelChatterDelegate delchatter = new DelChatterDelegate(DelChatter);
                            Invoke(delchatter, new object[] { tempMsg[2], form });
                        }

                        break;

                    case "dc": //���� ��ȭ�� ������ ���� ���� (dc|Formkey|id)

                        if (ChatFormList.ContainsKey(tempMsg[1]) && ChatFormList[tempMsg[1]] != null)
                        {
                            ChatForm form = (ChatForm)ChatFormList[tempMsg[1]];

                        }

                        break;

                    case "m"://�޸� ������ ��� m|name|id|message|������id
                        ArrangeCtrlDelegate memo = new ArrangeCtrlDelegate(MakeMemo);
                        Invoke(memo, new object[] { tempMsg });
                        MemoFileWrite(msg + "|" + DateTime.Now.ToString());
                        break;

                    case "F":  //�������� �� ���� ���� ����     F|���ϸ�|����ũ��|����key|������id
                        string name = getName(tempMsg[4]);
                        string[] filenameArray = tempMsg[1].Split('\\'); //���ϸ� ����
                        int filesize = int.Parse(tempMsg[2]);            //����ũ�� ij����
                        IPEndPoint siep = (IPEndPoint)InList[tempMsg[4]];
                        siep.Port = 8883;
                        string savefilename = "C:\\MiniCTI\\" + this.myid + "\\Files\\" + filenameArray[filenameArray.Length - 1];
                        if (InList.ContainsKey(tempMsg[4]) && InList[tempMsg[4]] != null)
                        {
                            Hashtable info = new Hashtable();
                            info[savefilename] = filesize;
                            info["name"] = name;
                            info["senderid"] = tempMsg[4];
                            SendMsg("Y|" + tempMsg[1] + "|" + tempMsg[3] + "|" + this.myid, siep); //����(Y|���ϸ�|����Key|������id)
                            FileReceiver((object)info);
                        }
                        downloadform.Show();
                        break;

                    case "Y"://���� �ޱ� ���� �޽���(Y|���ϸ�|����key|������id)
                        ShowFileSendDetailDelegate show = new ShowFileSendDetailDelegate(ShowFileSendDetail);
                        Hashtable table = new Hashtable();
                        table[tempMsg] = (IPEndPoint)InList[tempMsg[3]];

                        //���� ���� ������ ����
                        Thread sendfile = new Thread(new ParameterizedThreadStart(SendFile));
                        sendfile.Start((object)table);

                        FileSendThreadList[tempMsg[2] + "|" + tempMsg[3]] = sendfile;

                        FileSendDetailListView view = (FileSendDetailListView)FileSendDetailList[tempMsg[2]];
                        Invoke(show, new object[] { tempMsg[3], "���۴����", view });

                        break;

                    case "FS"://���� �ޱ� ���� �޽���(FS|���ϸ�|����key|������id)
                        ShowFileSendDetailDelegate show_ = new ShowFileSendDetailDelegate(ShowFileSendDetail);
                        Hashtable table_ = new Hashtable();
                        table_[tempMsg] = server;

                        //���� ���� ������ ����
                        Thread sendfile_ = new Thread(new ParameterizedThreadStart(SendFile));
                        sendfile_.Start((object)table_);

                        FileSendThreadList[tempMsg[2] + "|" + tempMsg[3]] = sendfile_;

                        FileSendDetailListView view_ = (FileSendDetailListView)FileSendDetailList[tempMsg[2]];
                        Invoke(show_, new object[] { tempMsg[3], "���۴����", view_ });

                        break;

                    case "N": //���� �ޱ� �ź�("N|���ϸ�|����Ű|id)

                        ShowFileSendDetailDelegate detail = new ShowFileSendDetailDelegate(ShowFileSendDetail);

                        FileSendDetailListView View = (FileSendDetailListView)FileSendDetailList[tempMsg[2]];

                        Invoke(detail, new object[] { tempMsg[3], "�ޱ� �ź�", View });

                        string Name = getName(tempMsg[3]);
                        string[] FilenameArray = tempMsg[1].Split('\\');
                        MessageBox.Show(Name + " ���� ���� �ޱ⸦ �ź��ϼ̽��ϴ�.\r\n\r\n���ϸ� : " + FilenameArray[(FilenameArray.Length - 1)], "�˸�", MessageBoxButtons.OK, MessageBoxIcon.Information);

                        break;

                    case "i":  //�߰� �α��� ������ ���  ���� : i|id|�Ҽ�����|ip|�̸�

                        try
                        {
                            //�α��� ����Ʈ ���̺�� �߰�
                            IPEndPoint addiep = new IPEndPoint(IPAddress.Parse(tempMsg[3]), 8883);
                            InList[tempMsg[1]] = addiep;
                            //memTree �信 �α��� ����� ���� ����
                            ChangeStat change = new ChangeStat(ChangeMemStat);
                            Invoke(change, new object[] { tempMsg[1], "online" });
                            TeamInfoList[tempMsg[1]] = tempMsg[2];

                        }
                        catch (Exception e)
                        {
                            logWrite(e.ToString());
                        }
                        break;

                    case "o":  //�α׾ƿ� ������ �߻��� ���  o|id|�Ҽ�
                        FormTextCtrlDelegate logoutchatter = new FormTextCtrlDelegate(LogoutChatter);
                        Invoke(logoutchatter, tempMsg[1]);
                        lock (this)
                        {
                            InList[tempMsg[1]] = null;
                        }
                        ChangeStat logout = new ChangeStat(ChangeLogout);
                        Invoke(logout, new object[] { tempMsg[1], tempMsg[2] });

                        break;

                    case "n":  //�������� �޽��� (n|�޽���|�߽���id|mode|noticetime|����)

                        logWrite("�������� ����!");
                        if (!tempMsg[2].Equals(this.myid)) //�ڱⰡ ���� ������ ��� ������ ����
                        {
                            ArrangeCtrlDelegate notice = new ArrangeCtrlDelegate(ShowNoticeDirect);
                            Invoke(notice, new object[] { tempMsg });
                        }

                        break;

                    case "A": //������ ���� ����(A|mnum|fnum|nnum|tnum)
                        ArrangeCtrlDelegate ShowAbsentInfo = new ArrangeCtrlDelegate(ShowAbsentInfoNumber);
                        Invoke(ShowAbsentInfo, new object[] { tempMsg });

                        break;

                    case "Q"://������ �޸� ����Ʈ (Q|sender;content;time;seqnum|sender;content;time;seqnum|...
                        ArrangeCtrlDelegate ShowNRmemoList = new ArrangeCtrlDelegate(ShowMemoList);
                        Invoke(ShowNRmemoList, new object[] { tempMsg });

                        break;

                    case "T"://������ ���� ����Ʈ (T|sender;content;time;mode;seqnum|sender;content;time;mode;seqnum|...
                        ArrangeCtrlDelegate ShowNRnoticeList = new ArrangeCtrlDelegate(ShowNotReadNoticeList);
                        Invoke(ShowNRnoticeList, new object[] { tempMsg });

                        break;

                    case "R"://������ ���� ����Ʈ (R|�������;filenum;filename;time;size;seqnum|�������;filenum;filename;time;size;seqnum|...
                        ArrangeCtrlDelegate ShowNRFileList = new ArrangeCtrlDelegate(ShowFileList);
                        Invoke(ShowNRFileList, new object[] { tempMsg });

                        break;

                    case "t": //"t|ntime��content��nmode��title�Ӿ��������1:���������2:...|...

                        ArrangeCtrlDelegate ShowNoticeResultFromDB = new ArrangeCtrlDelegate(showNoticeResultFromDB);
                        Invoke(ShowNoticeResultFromDB, new object[] { tempMsg });

                        break;

                    case "L"://�������� ����Ʈ ������ ���  L|time!content!mode!sender!seqnum
                        if (!(tempMsg.Length < 2))
                        {
                            ArrangeCtrlDelegate makeNoticeList = new ArrangeCtrlDelegate(MakeNoticeListForm);
                            Invoke(makeNoticeList, new object[] { tempMsg });
                        }
                        else
                        {
                            MessageBox.Show("��ϵ� ������ �����ϴ�.", "��������", MessageBoxButtons.OK);
                        }
                        break;

                    case "s"://�� Ŭ���̾�Ʈ ���°� ���� �޽��� s|id|����|IPAddress
                        if (!tempMsg[1].Equals(this.myid))
                        {
                            ChangeStat presenceupdate = new ChangeStat(PresenceUpdate);
                            Invoke(presenceupdate, new object[] { tempMsg[1], tempMsg[2] });
                            IPEndPoint tempiep = new IPEndPoint(IPAddress.Parse(tempMsg[3]), listenport);
                            lock (InList)
                            {
                                InList[tempMsg[1]] = tempiep;
                            }
                        }
                        break;

                    case "Ring": //�߽��� ǥ��(Ring|ani|name|server_type)

                        RingingDele ringdele = new RingingDele(Ringing);
                        Invoke(ringdele, new object[] { tempMsg[1], tempMsg[2], tempMsg[3] });

                        break;

                    case "Dial": //���̾�� ������� �˾�(Dial|ani)
                        if (this.nopop_outbound == false)
                        {
                            doublestringDele dialdele = new doublestringDele(Answer);
                            Invoke(dialdele, new object[] { tempMsg[1], "2" });
                        }
                        break;

                    case "Answer": //offhook�� ������� �˾�(Answer|ani|type)
                        doublestringDele answerdele = new doublestringDele(Answer);
                        Invoke(answerdele, new object[] { tempMsg[1], tempMsg[2] });

                        break;

                    case "Abandon": //Abandon �߻���
                        AbandonDele abandon = new AbandonDele(Abandoned);
                        Invoke(abandon);
                        break;

                    case "Other": //�ٸ������ �����
                        AbandonDele other = new AbandonDele(OtherAnswer);
                        Invoke(other);
                        break;

                    case "pass"://������� ���� ����(pass|ani|senderID|receiverID
                        if (tempMsg[2].Equals(this.myid))
                        {
                            //MessageBox.Show("�̰��Ǿ����ϴ�.");
                        }
                        else
                        {
                            //notifyTransfer(tempMsg);
                            ArrangeCtrlDelegate passdele = new ArrangeCtrlDelegate(notifyTransfer);
                            Invoke(passdele, new object[]{tempMsg});
                        }
                        break;

                    case "trans"://������ �̰� �޽ý� ����(trans|sender��content��time��seqnum|...)
                        ArrangeCtrlDelegate ShowNRTransList = new ArrangeCtrlDelegate(showNoreadTransfer);
                        Invoke(ShowNRTransList, new object[] { tempMsg });
                        break;

                }
            }
            catch (Exception exception)
            {
                logWrite(exception.StackTrace);
            }
        }