Ejemplo n.º 1
0
        private void c_ResponseReceive(CMPPClient Sender, ResponseEventArgs e)
        {
            CMPP_MESSAGE header = e.ResponseHeader;

            this.PrintHeader(header);
            byte[] bytes = new byte[header.TotalLength];
            e.ResponseHeaderData.CopyTo(bytes, 0);
            e.ResponseBodyData.CopyTo(bytes, CMPP_MESSAGE.HEAD_LENTH);
            string s = "";

            if (header.CommandId == CMPP_COMMAND_ID.CMPP_ACTIVE_TEST_RESP)
            {
                CMPP_ACTIVE_TEST_RESP response = new CMPP_ACTIVE_TEST_RESP(bytes);
                Console.WriteLine(response.Reserved);
            }
            else if (header.CommandId == CMPP_COMMAND_ID.CMPP_CONNECT_RESP)
            {
                CMPP_CONNECT_RESP response = new CMPP_CONNECT_RESP(bytes);
                s = String.Format("CMPP_CONNECT_RESP Status: {0}", response.Status);
            }
            else if (header.CommandId == CMPP_COMMAND_ID.CMPP_DELIVER)
            {
                CMPP_DELIVER response = new CMPP_DELIVER(bytes);
                //s = String.Format("CMPP_DELIVER : {0},{1}",response.Src_terminal_Id,response.Msg_Content);
                if (response.RegisteredDelivery == 0) //普通短信
                {
                    s = String.Format("收到普通短信: \n{0}\n{1}", response.SrcTerminalId, response.MsgContent);
                }
                else
                //该模拟器不能自动生成状态报告再下发!请自行键入下面短信内容后,发送
                //状态报告短信: 00000001DELIVRD031213505003121350501391xxx11381391xxx11381391xx11380001
                {
                    CMPP_MSG_CONTENT x = new CMPP_MSG_CONTENT(Encoding.ASCII.GetBytes(response.MsgContent));
                    s = String.Format("收到状态报告: \n{0}\n{1}", x.Stat, x.DestTerminalId);
                }
            }
            else if (header.CommandId == CMPP_COMMAND_ID.CMPP_QUERY_RESP)
            {
                CMPP_QUERY_RESP response = new CMPP_QUERY_RESP(bytes);
                s = String.Format("CMPP_QUERY_RESP: {0},{1}", response.Time, response.QueryCode);
            }
            else if (header.CommandId == CMPP_COMMAND_ID.CMPP_SUBMIT_RESP)
            {
                CMPP_SUBMIT_RESP response = new CMPP_SUBMIT_RESP(bytes);
                s = String.Format("CMPP_SUBMIT_RESP Msg_Id: {0}, Result: {1}", response.MsgId, response.Result);
            }
            else if (header.CommandId == CMPP_COMMAND_ID.CMPP_TERMINATE_RESP)
            {
                s = String.Format("good bye");
            }

            Console.WriteLine(s + "\n");
        }
Ejemplo n.º 2
0
 private void DealISMGMessage(CMPP_QUERY_RESP message)
 {
 }