CMPP的SUBMIT 包的CODE SAMPLE

发表于:2007-06-23来源:作者:点击数: 标签:
if(int(sLabel.size())100) return false; CPKMsg pkMsg; if(!pkMsg.stPK(sLabel,sBody)) { ostringstream oss; oss"Message is error.Leabel:"sLabel"Body:"sBody; gRunInfo.AddInfo(oss.str()); } int nPkNum = int(pkMsg.m_vBody.size()); for(int i=0;in

   

if(int(sLabel.size())<100) return false;
    CPKMsg pkMsg;
    if(!pkMsg.stPK(sLabel,sBody))
    {
        ostringstream oss;

        oss<<"Message is error.Leabel:"<<sLabel<<"Body:"<<sBody;
        gRunInfo.AddInfo(oss.str());
    }
    int nPkNum = int(pkMsg.m_vBody.size());
    for(int i=0;i<nPkNum;i++)
    {
        string sCurBody = pkMsg.m_vBody.at(i);  //要发送的Body,以字符窜显示

        long nSec = SequenceID();
        string sFeeType,sFeeCode,sSrvType;
        sFeeType = pkMsg.sFeeType;
        sFeeCode = pkMsg.sFeeCode;
        sSrvType = pkMsg.sServiceType;
        if(nPkNum>1) {                   //发送的肯定是铃声或图片,这时,只有最后一条是计费的
            if(i<(nPkNum-1)) {
                sFeeType ="01";
                sFeeCode ="0";
                if(pkMsg.sArea =="BJ") {sSrvType = "BZ";}
                else {sSrvType = "MF";}
            }
        }
        vector<BYTE> vCur;
        pkMsg.gtPKBody(i,vCur);   //获得当前要发送的内容,可以是二进制
        CSmsCmpp smCmpp(m_bAdd86);
        
        smCmpp.EncodeSubmit(nSec,
            1,
            1,
            pkMsg.nMsgMode,
            9,
            sSrvType,
            pkMsg.nFeeUserType,
            pkMsg.sFeeAddr,
            pkMsg.nMsgFmt,
            m_sSPID,
            sFeeType,
            sFeeCode,
            pkMsg.sOrgAddr,
            pkMsg.sDestAddr,
            vCur);
        m_DataSend.Write(smCmpp.GetPackage());
        
        if(pkMsg.nMsgMode==2) {
            Monitor(2,pkMsg.sOrgAddr,pkMsg.sDestAddr,pkMsg.nMsgFmt,int(strlen(sCurBody.c_str())),sCurBody);        
            m_nCount.SmcQueueAdd();
        }
        else {
            Monitor(1,pkMsg.sOrgAddr,pkMsg.sDestAddr,pkMsg.nMsgFmt,int(strlen(sCurBody.c_str())),sCurBody);        
            m_nCount.MTQueueADD();
        }

        string sCurLabel=pkMsg.gtLabel();  //获取当前的Label
        if(sFeeType=="01") {
            sCurLabel.replace(8,1,"1");
            sCurLabel.replace(9,4,"   0");
            if(sSrvType=="MF")    {
                sCurLabel.replace(13,6,"MF    ");
            }
            else if(sSrvType=="BZ")     {
                sCurLabel.replace(13,6,"BZ    ");
            }
        }
        m_DataList.AddSubmit(nSec,sCurLabel,sCurBody);
    }    
    return true;

原文转自:http://www.ltesting.net