示例#1
0
        private void do_udp_monitor()
        {
            object o = new object();

            lock (o)
            {
                while (times_repeat <= MAX_REPEAT_TIMES)
                {
                    try
                    {
                        byte[] b = udp_local.Receive(ref end_point_server);
                        string s = Encoding.UTF8.GetString(b);
                        msg_receive = new CJMsg(s);
                        if (CHCJ.MsgType.CS_REPLY == msg_receive.getMsgType())
                        {
                            send_state = SendState.OK;
                            receiveOver();
                            break;
                        }
                        else
                        {
                            send_state = SendState.SERVER_ERROR;
                            receiveOver();
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        ;
                    }
                }
            }
        }
示例#2
0
 private void tcp_moniter()
 {
     while (is_listening)
     {
         try
         {
             int readLen = tcp_client.Available;
             if (readLen > 0)
             {
                 byte[] getData = new byte[2048];
                 tcp_netstream.Read(getData, 0, getData.Length);
                 try
                 {
                     string getMsg = Encoding.UTF8.GetString(getData);
                     msg_receive = new CJMsg(getMsg);
                     send_state  = SendState.OK;
                     receiveOver(CJLog.LogLevel.DEBUG, "接收到消息" + getMsg);
                 }
                 catch (Exception ex)
                 {
                     send_state = SendState.SERVER_ERROR;
                     receiveOver(CJLog.LogLevel.COMMON_ERROR, "error: 接收数据后解析错误-" + ex.Message);
                 }
             }
         }
         catch (Exception)
         {
             receiveOver(CJLog.LogLevel.COMMON_ERROR, "error: 接收数据时出现错误");
         }
     }
 }
示例#3
0
 private void tcp_moniter()
 {
     while (true)
     {
         int readLen = tcp_client.Available;
         if (readLen > 0)
         {
             byte[] getData = new byte[2048];
             tcp_netstream.Read(getData, 0, getData.Length);
             string getMsg = Encoding.UTF8.GetString(getData);
             msg_receive = new CJMsg(getMsg);
             send_state  = SendState.OK;
             receiveOver();
         }
     }
 }
示例#4
0
        public List <CJMsg> getMsgTextVs(string type)
        {
            List <CJMsg> noReceive = new List <CJMsg>();
            XmlNode      noddata   = rootNode.SelectSingleNode("Data");

            foreach (XmlNode nodetext in noddata.SelectNodes("Text"))
            {
                if (((XmlElement)nodetext).GetAttribute("type") == type)
                {
                    string str = nodetext.InnerText;
                    str = System.Text.RegularExpressions.Regex.Replace(str, "&gt;", ">");
                    str = System.Text.RegularExpressions.Regex.Replace(str, "&lt;", "<");
                    CJMsg tmp = new CJMsg(str);
                    noReceive.Add(tmp);
                }
            }
            return(noReceive);
        }
示例#5
0
        // 登陆认证
        public void authUser()
        {
            CJMsg msg_send = new CJMsg();

            msg_send.setMsgType(MsgType.C_AUTH);
            msg_send.setMsgToNode(CJConfig.ServerIp.ToString(),
                                  CJConfig.ServerTcpPort,
                                  CJConfig.ServerID,
                                  CJConfig.ServerName);
            msg_send.setMsgFromNode(CJConfig.LocalIp.ToString(),
                                    conn.port_tcp_local,
                                    comboBox1.Text,
                                    "");
            msg_send.addMsgText(textBox2.Text);
            conn.msg_send = msg_send;
            conn.tcp_start();
            conn.tcp_sendMsg();
            log.loging(conn.msg_send.ToString(), CJLog.LogLevel.DEBUG);
        }