Ejemplo n.º 1
0
        //로그인 memberid, 선택된 유저, 처리구분 kb
        public void RunApp(String userId, String selectUserList, String kb)
        {
            Hashtable      _param = new Hashtable();
            UserDetailInfo udll   = new UserDetailInfo();

            udll = MainProg.getUserInfoByKey("MEMBERID", userId.Substring(1));

            //메세지보내기
            if (kb.Equals("sendMessage"))
            {
                //MessageFormBox mfb = new MessageFormBox(userId, selectUserList, client, null);
                MessageFormBox mfb = new MessageFormBox(userId, selectUserList, null);
                mfb.Show();
            }
            //유저정보보기
            else if (kb.Equals("viewUserInfo"))
            {
                //선택한 유저 정보 가져오기
                UserInfo uif = new UserInfo(udll);
                uif.Show();
            }
            //채팅하기
            else if (kb.Equals("sendChat"))
            {
                List <String> _ru = new List <string>();

                int _personCnt = 0;

                if (selectUserList != null && selectUserList.Length > 0)
                {
                    String[] rcvUsrId = selectUserList.Split('^');

                    //체크박스로 선택한 사람들
                    foreach (String item in rcvUsrId)
                    {
                        //체크안되고 선택되어진 인원 중복 제외
                        if (!item.Equals(userId) && item.Length > 0)
                        {
                            String memberId = MainProg.getUserInfoByKey("MEMBERID", item.Substring(1)).MEMBERID;
                            if (presentSessionList.Contains(memberId))
                            {
                                ++_personCnt;
                                //유저실제아이디로 치환(SESSION_KEY값)
                                _ru.Add(memberId);
                            }
                        }
                    }
                    //채팅 선택되어진 사람(체크박스없이)
                    if (presentSessionList.Contains(udll.MEMBERID))
                    {
                        ++_personCnt;
                        //유저실제아이디로 치환(SESSION_KEY값)
                        _ru.Add(udll.MEMBERID);
                    }
                }
                else
                {
                    if (presentSessionList.Contains(udll.MEMBERID))
                    {
                        ++_personCnt;
                        //유저실제아이디로 치환(SESSION_KEY값)
                        _ru.Add(udll.MEMBERID);
                    }
                }

                //로그인된사람이 하나도 없으면 채팅불가
                if (_personCnt < 1)
                {
                    MessageBox.Show("로그인 된 참여자가 존재하지 않습니다.");
                    return;
                }

                //채팅창 만든사람
                _ru.Add(_userId);

                //채팅창을 오픈
                ChatForm cf = new ChatForm(true, null, _userId, _ru);

                //채팅창에 받은 메세지를 넘겨줄 수 있도록 처리(MAINFORM => CHATFORM)
                this.DataSendEvent += new DataPushEventHandler(cf.SetActiveValue);
                cf.DataSendEvent   += new DataGetEventHandlder(this.DataAction);

                cf.Show();
            }
        }
Ejemplo n.º 2
0
        //데이터 받았을 때 발생하는 이벤트
        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);
            //}
        }