CMPP的SUBMIT 包的CODE SAMPLE
发布时间:2006-10-14 3:03:12   收集提供:gaoqian

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;

 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50