//공지사항 삭제 이벤트 private void noticeDel_Click(object sender, EventArgs e) { String noticeNum = string.Empty; if (lv_notice.SelectedItems.Count == 1) { ListView.SelectedListViewItemCollection items = lv_notice.SelectedItems; foreach (ListViewItem item in items) { noticeNum = item.SubItems[0].Text; if (!item.SubItems[4].Text.Equals(MainProg.GetUserId())) { MessageBox.Show("작성자만 삭제할 수 있습니다."); return; } } if (MessageBox.Show("선택하신 공지를 삭제하시겠습니까?", "YesOrNo", MessageBoxButtons.YesNo) == DialogResult.Yes) { //Hashtable _param = new Hashtable(); //_param.Add("C_INDEX", noticeNum); //_ins.DeleteHashData(_param, "delBoard"); PacketData_SendNotice req = new PacketData_SendNotice(); req.noticeNum = Int32.Parse(noticeNum); req.noticeProcess = "D"; MainProg.client.Send(req); MessageBox.Show("삭제되었습니다."); //ShowBoard(false, null); } } }
void worker_RunWorkerCompleted_Ftp(object sender, RunWorkerCompletedEventArgs e) { backgroundWorker1.DoWork -= new DoWorkEventHandler(uploadFileFtp); backgroundWorker1.ProgressChanged -= new ProgressChangedEventHandler(worker_ProgressChanged_Ftp); backgroundWorker1.RunWorkerCompleted -= new RunWorkerCompletedEventHandler(worker_RunWorkerCompleted_Ftp); if (e.Error == null) { download_panel.Visible = false; MessageBox.Show("등록 되었습니다."); PacketData_SendNotice req = new PacketData_SendNotice(); req.userId = MainProg.GetUserId(); req.boardNo = boardNo; MainProg.client.Send(req); this.DataPushEvent_Sub(false); this.Dispose(); } }
private void btn_Snd_msg_Click(object sender, EventArgs e) { if (txt_NoticeTItle.Text.Equals("")) { MessageBox.Show("제목이 입력되어 있지 않습니다."); return; } Hashtable _param = new Hashtable(); _param.Add("TITLE", txt_NoticeTItle.Text); _param.Add("CONTEXT", NoticeBody.DocumentText); _param.Add("REGI_ID", MainProg.GetUserId()); _param.Add("MESSAGE_KB", "0"); for (int i = 0; i < lvFileList.Items.Count; i++) { ListViewItem fItem = lvFileList.Items[i]; switch (i) { case 0: _param.Add("FILE_", fItem.SubItems[2].Text); _param.Add("FILE_ORIGIN", fItem.SubItems[0].Text); break; case 1: _param.Add("FILE1_", fItem.SubItems[2].Text); _param.Add("FILE1_ORIGIN", fItem.SubItems[0].Text); break; case 2: _param.Add("FILE2_", fItem.SubItems[2].Text); _param.Add("FILE2_ORIGIN", fItem.SubItems[0].Text); break; case 3: _param.Add("FILE3_", fItem.SubItems[2].Text); _param.Add("FILE3_ORIGIN", fItem.SubItems[0].Text); break; case 4: _param.Add("FILE3_", fItem.SubItems[2].Text); _param.Add("FILE4_", fItem.SubItems[0].Text); break; } } if (chkLimit.Checked) { DateTime dt = limitDate.Value; _param.Add("DISPLAY_DT", dt.Year.ToString() + (dt.Month < 10?"0" + dt.Month.ToString():dt.Month.ToString()) + (dt.Day < 10 ? "0" + dt.Day.ToString() : dt.Day.ToString())); } else { _param.Add("DISPLAY_DT", "99991231"); } //공지사항 번호가 있으면 수정, 없으면 등록 if (BoardNo.Text != "") { _param.Add("C_INDEX", BoardNo.Text); //변경일 경우 //_ins.UpdatetHashData(_param, "updateBoard"); //boardNo = Int32.Parse(BoardNo.Text); PacketData_SendNotice req = new PacketData_SendNotice(); req.userId = MainProg.GetUserId(); req.noticeNum = Int32.Parse(BoardNo.Text); req.noticeDetail = _param; req.noticeProcess = "U"; MainProg.client.Send(req); MessageBox.Show("수정 되었습니다."); //this.DataPushEvent_Sub(false, null); this.Dispose(); } else { download_panel.Visible = true; PacketData_SendNotice req = new PacketData_SendNotice(); req.userId = MainProg.GetUserId(); //req.noticeNum = boardNo; req.noticeProcess = "I"; req.noticeDetail = _param; MainProg.client.Send(req); //추가일 경우 //boardNo = _ins.InsertHashDataBySelectKey(_param, "insertBoard"); FileUpload(); } }
//데이터 받았을 때 발생하는 이벤트 void OnReceive(Client sender, int msgType, byte[] buff) { string s = System.Text.Encoding.UTF8.GetString(buff); JObject jObject = JObject.Parse(s); int packetID = (int)jObject["PacketID"]; PacketResponse response = new PacketResponse((PacketID)packetID, s); if (packetID == (int)PacketID.PacketID_Connect_Req) { PacketData_ConnectReq req = response.Parsing <PacketData_ConnectReq>(); String _connetedUsers = String.Empty; Invoke((MethodInvoker) delegate { //처음 실행시 가져오는 전체유저정보취득 MainProg.Instance.getUserLIst(req.userList); //처음 실행시 가져오는 공지사항 if (req.noticeList != null) { ShowBoard(true, req.noticeList); } //처음 실행시 가져오는 읽지 않은 메세지 if (req.messageList != null) { getReadMessage(req.messageList); } //로그인한 사람 저장 presentSessionList = req.presentSessionList; }); foreach (String users in presentSessionList) { _connetedUsers += "F" + users + "^"; } //로그인하면 화면 처리(로그인한사람) this.Invoke(new Action(() => { webBrowser1.Document.InvokeScript("onLineMark", new object[] { _connetedUsers }); })); } else if (packetID == (int)PacketID.PacketID_DisConnect_Req) { PacketData_DisConnectReq req = response.Parsing <PacketData_DisConnectReq>(); String _connetedUsers = String.Empty; _connetedUsers += "F" + req.userId + "^"; //로그아웃이나 종료하면 화면 처리(로그인한사람) this.Invoke(new Action(() => { webBrowser1.Document.InvokeScript("offLineMark", new object[] { _connetedUsers }); })); } //공지사항 보기 else if (packetID == (int)PacketID.PacketID_Notice_Detail) { PacketData_NoticeDetail req = response.Parsing <PacketData_NoticeDetail>(); Invoke((MethodInvoker) delegate { //ShowBoard(false); //수정을 눌렀을 때 if (req.noticeProcess.Equals("U")) { NoticeWrite ni = new NoticeWrite(req.noticeDetail, req.noticeNum); // ni.DataPushEvent_Sub += new NoticeWrite.Sub_DataPushEventHandler(ShowBoard); ni.Show(); } else { NoticeView nv = new NoticeView(req.noticeDetail); nv.Show(); } }); } //공지사항 등록 및 수정시 else if (packetID == (int)PacketID.PacketID_Send_Notice) { PacketData_SendNotice req = response.Parsing <PacketData_SendNotice>(); Invoke((MethodInvoker) delegate { if (req.noticeProcess.Equals("D")) { ShowBoard(false, req.noticeList); } else { ShowBoard(true, req.noticeList); } //NoticeView nv = new NoticeView(req.boardNo.ToString()); //nv.Show(); }); } //공지사항 찾기 else if (packetID == (int)PacketID.PacketID_Notice_Find) { PacketData_NoticeFind req = response.Parsing <PacketData_NoticeFind>(); Invoke((MethodInvoker) delegate { ShowBoard(false, req.noticeList); }); } //메세지 관리함 보기 else if (packetID == (int)PacketID.PacketID_Message_Mng) { PacketData_MessageMng req = response.Parsing <PacketData_MessageMng>(); Invoke((MethodInvoker) delegate { Form fc = Application.OpenForms["MessageMng"]; if (fc != null) { DataSendMessageEvent(req.messageList, null, "1"); } else { MessageMng mv = new MessageMng(req.messageList); this.DataSendMessageEvent += new DataPushMessageEventHandler(mv.SetActiveValue); mv.DataSendMessageEvent += new DataGetMessageEventHandlder(this.DataMessageAction); mv.ShowDialog(); } }); } //메세지 상세보기 else if (packetID == (int)PacketID.PacketID_Message_Detail) { PacketData_MessageDetail req = response.Parsing <PacketData_MessageDetail>(); Invoke((MethodInvoker) delegate { DataSendMessageEvent(req.messageDetail, req.messageReaderDetail, null); }); } //메세지 찾기 else if (packetID == (int)PacketID.PacketID_Message_Search) { PacketData_MessageSearch req = response.Parsing <PacketData_MessageSearch>(); Invoke((MethodInvoker) delegate { DataSendMessageEvent(req.messageList, null, "1"); }); } //메세지 회신쓰기 else if (packetID == (int)PacketID.PacketID_Message_ReWrite) { PacketData_MessageReWrite req = response.Parsing <PacketData_MessageReWrite>(); Invoke((MethodInvoker) delegate { //DataSendMessageEvent(req.messageDetail, null, "1"); MessageFormBox mfb = new MessageFormBox(req.rcvUser, null, req.messageDetail); mfb.Show(); }); } //메세지 받기 else if (packetID == (int)PacketID.PacketID_Send_Msg) { PacketData_SendMessage req = response.Parsing <PacketData_SendMessage>(); Invoke((MethodInvoker) delegate { //MessageView mv = new MessageView(req.boardNo.ToString()); Form fc = Application.OpenForms["MessageMng"]; if (fc != null) { PacketData_MessageMng req_2 = new PacketData_MessageMng(); Hashtable _param = new Hashtable(); _param.Add("MESSAGE_KB", "1"); _param.Add("REGI_ID", MainProg.GetUserId()); req_2.criInfo = _param; req_2.process = "1"; MainProg.client.Send(req_2); } MessageView mv = new MessageView(req.messageDetail, req.userId, req.boardNo); mv.Show(); }); } //채팅방 만들기 else if (packetID == (int)PacketID.PacketID_Make_Room) { PacketData_MakeRoom req = response.Parsing <PacketData_MakeRoom>(); Invoke((MethodInvoker) delegate { if (!_userId.Equals(req.makeUserId)) { ChatForm cf = new ChatForm(false, req, _userId, null); this.DataSendEvent += new DataPushEventHandler(cf.SetActiveValue); cf.DataSendEvent += new DataGetEventHandlder(this.DataAction); cf.Show(); } }); } //방없애기 else if (packetID == (int)PacketID.PacketID_Close_Room) { PacketData_CloseRoom req = response.Parsing <PacketData_CloseRoom>(); Invoke((MethodInvoker) delegate { DataSendEvent("close_theRoom", req.roomNo, req.userId); }); } //방채팅 else if (packetID == (int)PacketID.PacketID_Room_Msg) { PacketData_SendRoomMessage req = response.Parsing <PacketData_SendRoomMessage>(); Invoke((MethodInvoker) delegate { rb2.Text += req.message; DataSendEvent(req.message, req.roomNo, req.sendUserId); }); } //조직도 Reload else if (packetID == (int)PacketID.PacketID_ReloadGroup) { //화면 리로드 처리 webBrowser1.Refresh(); } //else //{ // RecvConnectAck(sender, response); //} }
//데이터 받았을 때 발생하는 이벤트 void OnReceive(Client sender, int msgType, byte[] buff) { string s = System.Text.Encoding.UTF8.GetString(buff); JObject jObject = JObject.Parse(s); int packetID = (int)jObject["PacketID"]; PacketResponse response = new PacketResponse((PacketID)packetID, s); if (packetID == (int)PacketID.PacketID_Connect_Req) { PacketData_ConnectReq req = response.Parsing <PacketData_ConnectReq>(); String _connetedUsers = String.Empty; Invoke((MethodInvoker) delegate { //로그인한 사람 저장 presentSessionList = req.presentSessionList; }); foreach (String users in presentSessionList) { _connetedUsers += "F" + users + "^"; } //로그인하면 화면 처리(로그인한사람) this.Invoke(new Action(() => { webBrowser1.Document.InvokeScript("onLineMark", new object[] { _connetedUsers }); })); } else if (packetID == (int)PacketID.PacketID_DisConnect_Req) { PacketData_DisConnectReq req = response.Parsing <PacketData_DisConnectReq>(); String _connetedUsers = String.Empty; _connetedUsers += "F" + req.userId + "^"; //로그아웃이나 종료하면 화면 처리(로그인한사람) this.Invoke(new Action(() => { webBrowser1.Document.InvokeScript("offLineMark", new object[] { _connetedUsers }); })); } //공지사항 등록 및 수정시 else if (packetID == (int)PacketID.PacketID_Send_Notice) { PacketData_SendNotice req = response.Parsing <PacketData_SendNotice>(); Invoke((MethodInvoker) delegate { ShowBoard(false); NoticeView nv = new NoticeView(req.boardNo.ToString()); nv.Show(); }); } //메세지 받기 else if (packetID == (int)PacketID.PacketID_Send_Msg) { PacketData_SendMessage req = response.Parsing <PacketData_SendMessage>(); Invoke((MethodInvoker) delegate { MessageView mv = new MessageView(req.boardNo.ToString()); mv.Show(); }); } //채팅방 만들기 else if (packetID == (int)PacketID.PacketID_Make_Room) { PacketData_MakeRoom req = response.Parsing <PacketData_MakeRoom>(); Invoke((MethodInvoker) delegate { if (!_userId.Equals(req.makeUserId)) { ChatForm cf = new ChatForm(false, req, _userId, null); this.DataSendEvent += new DataPushEventHandler(cf.SetActiveValue); cf.DataSendEvent += new DataGetEventHandlder(this.DataAction); cf.Show(); } }); } //방없애기 else if (packetID == (int)PacketID.PacketID_Close_Room) { PacketData_CloseRoom req = response.Parsing <PacketData_CloseRoom>(); Invoke((MethodInvoker) delegate { DataSendEvent("close_theRoom", req.roomNo, req.userId); }); } //방채팅 else if (packetID == (int)PacketID.PacketID_Room_Msg) { PacketData_SendRoomMessage req = response.Parsing <PacketData_SendRoomMessage>(); Invoke((MethodInvoker) delegate { rb2.Text += req.message; DataSendEvent(req.message, req.roomNo, req.sendUserId); }); } //조직도 Reload else if (packetID == (int)PacketID.PacketID_ReloadGroup) { //화면 리로드 처리 webBrowser1.Refresh(); } //else //{ // RecvConnectAck(sender, response); //} }
//클라이언트에서 넘어오는 데이터 처리 void SessionRecvData(Session sender, RecvBuff e) { if (e.msgType == (int)MsgType.String) { string s = System.Text.Encoding.UTF8.GetString(e.memoryStream.ToArray()); JObject jObject = JObject.Parse(s); Int32 packetID = (Int32)jObject["PacketID"]; PacketResponse response = new PacketResponse((PacketID)packetID, s); if (packetID == (int)PacketID.PacketID_Connect_Req) { PacketData_ConnectReq req = response.Parsing <PacketData_ConnectReq>(); RecvConnectReq(sender, response); //로그인 한 사람이 있으면 각 클라이언트 리스트를 전달한다. List <String> presentSessionList = new List <string>(); //현재로그인 인원 foreach (Session session in sessionList) { presentSessionList.Add(session.userId); } req.presentSessionList = presentSessionList; //유저정보를 취득하여 보낸다. req.userList = _db.getUserLIst(); //로그인인원에게 리스트 갱신처리 foreach (Session session in sessionList) { // 로그인한사람의 리스트 처리 if (session.userId.Equals(sender.userId)) { //공지사항 리스트를 가져간다. req.noticeList = _db.getNoticeList(); //메세지 리스트를 가져간다. req.messageList = _db.getUnReadBoarderDetail(sender.userId); } else { req.noticeList = null; req.messageList = null; } session.Send(req); } } else if (packetID == (int)PacketID.PacketID_Notice_Detail) { PacketData_NoticeDetail req = response.Parsing <PacketData_NoticeDetail>(); Invoke((MethodInvoker) delegate { req.noticeDetail = _db.getNoticeDetail(req.noticeNum, sender.userId); Session session = GetSessionFromList(sender.userId); if (session != null) { session.Send(req); } }); } else if (packetID == (int)PacketID.PacketID_Send_Notice) { PacketData_SendNotice req = response.Parsing <PacketData_SendNotice>(); int boardNo = 0; if (req.noticeProcess.Equals("U")) { _db.updateNoticeDetail(req.noticeDetail); boardNo = req.noticeNum; req.noticeProcess = "R"; } else if (req.noticeProcess.Equals("D")) { _db.deleteNoticeDetail(req.noticeNum); req.noticeProcess = "D"; } else { req.noticeDetail.Add("ID_READER", sender.userId); _db.insertNoticeDetail(req.noticeDetail); req.noticeProcess = "R"; } //req.boardNo = boardNo; //처리 후 읽기 모드 req.noticeList = _db.getNoticeList(); //req.noticeDetail_Rev = _db.getNoticeDetail(boardNo.ToString(), sender.userId); Invoke((MethodInvoker) delegate { //로그인되어 있는 사람 모드에게 오픈처리 foreach (Session session in sessionList) { session.Send(req); } }); } else if (packetID == (int)PacketID.PacketID_Notice_Find) { PacketData_NoticeFind req = response.Parsing <PacketData_NoticeFind>(); req.noticeList = _db.getNoticeListFind(req.criFind); Invoke((MethodInvoker) delegate { Session session = GetSessionFromList(sender.userId); if (session != null) { session.Send(req); } }); } //메세지 관리함 else if (packetID == (int)PacketID.PacketID_Message_Mng) { PacketData_MessageMng req = response.Parsing <PacketData_MessageMng>(); Invoke((MethodInvoker) delegate { req.messageList = _db.getBoarderRcvList(req.criInfo); Session session = GetSessionFromList(sender.userId); if (session != null) { session.Send(req); } }); } //메세지 상세보기 else if (packetID == (int)PacketID.PacketID_Message_Detail) { PacketData_MessageDetail req = response.Parsing <PacketData_MessageDetail>(); Invoke((MethodInvoker) delegate { req.messageDetail = _db.getMessageDetail(req.criInfo); req.messageReaderDetail = _db.getMessageReaderDetail(req.criInfo); Session session = GetSessionFromList(sender.userId); if (session != null) { session.Send(req); } }); } //메세지 검색하기 else if (packetID == (int)PacketID.PacketID_Message_Search) { PacketData_MessageSearch req = response.Parsing <PacketData_MessageSearch>(); Invoke((MethodInvoker) delegate { req.messageList = _db.getBoarderRcvList(req.criInfo); Session session = GetSessionFromList(sender.userId); if (session != null) { session.Send(req); } }); } //메세지 회신 else if (packetID == (int)PacketID.PacketID_Message_ReWrite) { PacketData_MessageReWrite req = response.Parsing <PacketData_MessageReWrite>(); req.messageDetail = _db.getMessageDetail(req.criInfo); Invoke((MethodInvoker) delegate { Session session = GetSessionFromList(sender.userId); if (session != null) { session.Send(req); } }); } //메세지 보내기 else if (packetID == (int)PacketID.PacketID_Send_Msg) { PacketData_SendMessage req = response.Parsing <PacketData_SendMessage>(); int boardNo = _db.insertMessageDetail(req.messageDetail, req.revUserId, sender.userId); req.boardNo = boardNo; Invoke((MethodInvoker) delegate { foreach (String rcvUser in req.revUserId) { Session session = GetSessionFromList(rcvUser); if (session != null) { session.Send(req); } } }); } //메세지 읽기 처리 else if (packetID == (int)PacketID.PacketID_Send_Msg_Read) { PacketData_SendMessage_Read req = response.Parsing <PacketData_SendMessage_Read>(); _db.updateBoardDetail(req.criInfo); } else if (packetID == (int)PacketID.PacketID_Make_Room) { PacketData_MakeRoom req = response.Parsing <PacketData_MakeRoom>(); Invoke((MethodInvoker) delegate { lv_roomList.BeginUpdate(); ListViewItem lvi = new ListViewItem(req.roomNo); Room _room = new Room(); lv_roomList.Items.Add(lvi); List <Session> _roomSessionList = new List <Session>(); foreach (String rcvUser in req.revUserId) { Session session = GetSessionFromList(rcvUser); if (session != null) { _roomSessionList.Add(session); session.Send(req); } } lv_roomList.EndUpdate(); //방의 소유주 _room.mainUserID = req.makeUserId; _room.roomNo = req.roomNo; _room.sessionList = _roomSessionList; roomList.Add(_room); }); } else if (packetID == (int)PacketID.PacketID_Close_Room) { PacketData_CloseRoom req = response.Parsing <PacketData_CloseRoom>(); Invoke((MethodInvoker) delegate { var toRemoveRoom = new List <String>(); foreach (Room _item in roomList) { if (_item.roomNo.Equals(req.roomNo)) { int idx = 0; var toRemoveSession = new List <String>(); while (idx < _item.sessionList.Count) { Session session = _item.sessionList[idx]; if (session.userId.Equals(req.userId)) { toRemoveSession.Add(session.userId); session = null; } if (session != null) { session.Send(req); } ++idx; } _item.sessionList.RemoveAll(d => toRemoveSession.Contains(d.userId)); if (_item.sessionList.Count < 1) { toRemoveRoom.Add(_item.roomNo); lv_roomList.BeginUpdate(); for (int i = 0; i < lv_roomList.Items.Count; i++) { ListViewItem fItem = lv_roomList.Items[i]; if (fItem.SubItems[0].Text.Equals(req.roomNo)) { fItem.Remove(); break; } } lv_roomList.EndUpdate(); } } } roomList.RemoveAll(d => toRemoveRoom.Contains(d.roomNo)); }); } else if (packetID == (int)PacketID.PacketID_Room_Msg) { PacketData_SendRoomMessage req = response.Parsing <PacketData_SendRoomMessage>(); Invoke((MethodInvoker) delegate { recvBox.Text += req.message; foreach (Room _item in roomList) { if (_item.roomNo.Equals(req.roomNo)) { foreach (Session session in _item.sessionList) { if (session != null) { session.Send(req); } } } } }); } } else if (e.msgType == (int)MsgType.File) { } }
//클라이언트에서 넘어오는 데이터 처리 void SessionRecvData(Session sender, RecvBuff e) { if (e.msgType == (int)MsgType.String) { string s = System.Text.Encoding.UTF8.GetString(e.memoryStream.ToArray()); JObject jObject = JObject.Parse(s); Int32 packetID = (Int32)jObject["PacketID"]; PacketResponse response = new PacketResponse((PacketID)packetID, s); if (packetID == (int)PacketID.PacketID_Connect_Req) { PacketData_ConnectReq req = response.Parsing <PacketData_ConnectReq>(); RecvConnectReq(sender, response); //로그인 한 사람이 있으면 각 클라이언트 리스트를 전달한다. List <String> presentSessionList = new List <string>(); //현재로그인 인원 foreach (Session session in sessionList) { presentSessionList.Add(session.userId); } req.presentSessionList = presentSessionList; //로그인인원에게 리스트 갱신처리 foreach (Session session in sessionList) { session.Send(req); } } else if (packetID == (int)PacketID.PacketID_Send_Notice) { PacketData_SendNotice req = response.Parsing <PacketData_SendNotice>(); Invoke((MethodInvoker) delegate { //로그인되어 있는 사람 모드에게 오픈처리 foreach (Session session in sessionList) { session.Send(req); } }); } else if (packetID == (int)PacketID.PacketID_Send_Msg) { PacketData_SendMessage req = response.Parsing <PacketData_SendMessage>(); Invoke((MethodInvoker) delegate { foreach (String rcvUser in req.revUserId) { Session session = GetSessionFromList(rcvUser); if (session != null) { session.Send(req); } } }); } else if (packetID == (int)PacketID.PacketID_Make_Room) { PacketData_MakeRoom req = response.Parsing <PacketData_MakeRoom>(); Invoke((MethodInvoker) delegate { lv_roomList.BeginUpdate(); ListViewItem lvi = new ListViewItem(req.roomNo); Room _room = new Room(); lv_roomList.Items.Add(lvi); List <Session> _roomSessionList = new List <Session>(); foreach (String rcvUser in req.revUserId) { Session session = GetSessionFromList(rcvUser); if (session != null) { _roomSessionList.Add(session); session.Send(req); } } lv_roomList.EndUpdate(); //방의 소유주 _room.mainUserID = req.makeUserId; _room.roomNo = req.roomNo; _room.sessionList = _roomSessionList; roomList.Add(_room); }); } else if (packetID == (int)PacketID.PacketID_Close_Room) { PacketData_CloseRoom req = response.Parsing <PacketData_CloseRoom>(); Invoke((MethodInvoker) delegate { var toRemoveRoom = new List <String>(); foreach (Room _item in roomList) { if (_item.roomNo.Equals(req.roomNo)) { int idx = 0; var toRemoveSession = new List <String>(); while (idx < _item.sessionList.Count) { Session session = _item.sessionList[idx]; if (session.userId.Equals(req.userId)) { toRemoveSession.Add(session.userId); session = null; } if (session != null) { session.Send(req); } ++idx; } _item.sessionList.RemoveAll(d => toRemoveSession.Contains(d.userId)); if (_item.sessionList.Count < 1) { toRemoveRoom.Add(_item.roomNo); lv_roomList.BeginUpdate(); for (int i = 0; i < lv_roomList.Items.Count; i++) { ListViewItem fItem = lv_roomList.Items[i]; if (fItem.SubItems[0].Text.Equals(req.roomNo)) { fItem.Remove(); break; } } lv_roomList.EndUpdate(); } } } roomList.RemoveAll(d => toRemoveRoom.Contains(d.roomNo)); }); } else if (packetID == (int)PacketID.PacketID_Room_Msg) { PacketData_SendRoomMessage req = response.Parsing <PacketData_SendRoomMessage>(); Invoke((MethodInvoker) delegate { recvBox.Text += req.message; foreach (Room _item in roomList) { if (_item.roomNo.Equals(req.roomNo)) { foreach (Session session in _item.sessionList) { if (session != null) { session.Send(req); } } } } }); } } else if (e.msgType == (int)MsgType.File) { } }