首页 > 学院 > 网络通信 > 正文

CMPP的SUBMIT 包的CODE SAMPLE

2019-11-04 22:06:52
字体:
来源:转载
供稿:网友

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;




上一篇:CMPP ACTIVE TEST

下一篇:CMPP CONNECT CODE SAMPLE

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表