Search in sources :

Example 6 with CmppReportRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppReportRequestMessage in project SMSGate by Lihuanghe.

the class TestSMPP2CMPPDeliverCodec method testReportCodec.

@Test
public void testReportCodec() {
    CmppDeliverRequestMessage msg = createTestReq("k k k ");
    msg.setMsgContent((SmsMessage) null);
    CmppReportRequestMessage reportRequestMessage = new CmppReportRequestMessage();
    reportRequestMessage.setSmscSequence(0x1234L);
    reportRequestMessage.setMsgId(new MsgId());
    reportRequestMessage.setDestterminalId("13800138000");
    reportRequestMessage.setStat("9876");
    msg.setReportRequestMessage(reportRequestMessage);
    test0(msg);
}
Also used : CmppDeliverRequestMessage(com.zx.sms.codec.cmpp.msg.CmppDeliverRequestMessage) CmppReportRequestMessage(com.zx.sms.codec.cmpp.msg.CmppReportRequestMessage) MsgId(com.zx.sms.common.util.MsgId) Test(org.junit.Test)

Example 7 with CmppReportRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppReportRequestMessage in project SMSGate by Lihuanghe.

the class CMPPResponseSenderHandler method channelRead.

@Override
public void channelRead(final ChannelHandlerContext ctx, Object msg) throws Exception {
    // 此时未经过长短信合并
    if (msg instanceof CmppDeliverRequestMessage) {
        CmppDeliverRequestMessage e = (CmppDeliverRequestMessage) msg;
        CmppDeliverResponseMessage responseMessage = new CmppDeliverResponseMessage(e.getHeader().getSequenceId());
        responseMessage.setResult(0);
        responseMessage.setMsgId(e.getMsgId());
        ctx.channel().writeAndFlush(responseMessage);
    } else if (msg instanceof CmppSubmitRequestMessage) {
        CmppSubmitRequestMessage e = (CmppSubmitRequestMessage) msg;
        CmppSubmitResponseMessage resp = new CmppSubmitResponseMessage(e.getHeader().getSequenceId());
        resp.setResult(0);
        ctx.channel().writeAndFlush(resp);
        if (e.getRegisteredDelivery() == 1) {
            final CmppDeliverRequestMessage deliver = new CmppDeliverRequestMessage();
            deliver.setDestId(e.getSrcId());
            deliver.setSrcterminalId(e.getDestterminalId()[0]);
            CmppReportRequestMessage report = new CmppReportRequestMessage();
            report.setDestterminalId(deliver.getSrcterminalId());
            report.setMsgId(resp.getMsgId());
            String t = DateFormatUtils.format(CachedMillisecondClock.INS.now(), "yyMMddHHmm");
            report.setSubmitTime(t);
            report.setDoneTime(t);
            report.setStat("DELIVRD");
            report.setSmscSequence(0);
            deliver.setReportRequestMessage(report);
            ctx.executor().submit(new Runnable() {

                public void run() {
                    ctx.channel().writeAndFlush(deliver);
                }
            });
        }
    } else if (msg instanceof CmppQueryRequestMessage) {
        CmppQueryRequestMessage e = (CmppQueryRequestMessage) msg;
        CmppQueryResponseMessage res = new CmppQueryResponseMessage(e.getHeader().getSequenceId());
        ctx.channel().writeAndFlush(res);
    }
    ctx.fireChannelRead(msg);
}
Also used : CmppQueryRequestMessage(com.zx.sms.codec.cmpp.msg.CmppQueryRequestMessage) CmppQueryResponseMessage(com.zx.sms.codec.cmpp.msg.CmppQueryResponseMessage) CmppDeliverRequestMessage(com.zx.sms.codec.cmpp.msg.CmppDeliverRequestMessage) CmppDeliverResponseMessage(com.zx.sms.codec.cmpp.msg.CmppDeliverResponseMessage) CmppReportRequestMessage(com.zx.sms.codec.cmpp.msg.CmppReportRequestMessage) CmppSubmitRequestMessage(com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage) CmppSubmitResponseMessage(com.zx.sms.codec.cmpp.msg.CmppSubmitResponseMessage)

Example 8 with CmppReportRequestMessage

use of com.zx.sms.codec.cmpp.msg.CmppReportRequestMessage in project SMSGate by Lihuanghe.

the class TestCmpp20DeliverRequestMessageCodec method testReportCodec.

@Test
public void testReportCodec() {
    CmppDeliverRequestMessage msg = createTestReq("k k k ");
    CmppReportRequestMessage reportRequestMessage = new CmppReportRequestMessage();
    reportRequestMessage.setSmscSequence(0x1234L);
    reportRequestMessage.setMsgId(new MsgId());
    reportRequestMessage.setDestterminalId("13800138000");
    reportRequestMessage.setStat("9876");
    msg.setReportRequestMessage(reportRequestMessage);
    test0(msg);
}
Also used : CmppDeliverRequestMessage(com.zx.sms.codec.cmpp.msg.CmppDeliverRequestMessage) CmppReportRequestMessage(com.zx.sms.codec.cmpp.msg.CmppReportRequestMessage) MsgId(com.zx.sms.common.util.MsgId) Test(org.junit.Test)

Aggregations

CmppDeliverRequestMessage (com.zx.sms.codec.cmpp.msg.CmppDeliverRequestMessage)8 CmppReportRequestMessage (com.zx.sms.codec.cmpp.msg.CmppReportRequestMessage)8 MsgId (com.zx.sms.common.util.MsgId)3 ByteBuf (io.netty.buffer.ByteBuf)3 Test (org.junit.Test)3 SmsDcs (org.marre.sms.SmsDcs)3 CmppDeliverResponseMessage (com.zx.sms.codec.cmpp.msg.CmppDeliverResponseMessage)2 CmppQueryRequestMessage (com.zx.sms.codec.cmpp.msg.CmppQueryRequestMessage)2 CmppQueryResponseMessage (com.zx.sms.codec.cmpp.msg.CmppQueryResponseMessage)2 CmppSubmitRequestMessage (com.zx.sms.codec.cmpp.msg.CmppSubmitRequestMessage)2 CmppSubmitResponseMessage (com.zx.sms.codec.cmpp.msg.CmppSubmitResponseMessage)2 ArrayList (java.util.ArrayList)1