use of com.zx.sms.codec.cmpp.msg.CmppSubmitResponseMessage in project SMSGate by Lihuanghe.
the class CmppSubmitResponseMessageCodec method decode.
@Override
protected void decode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
int commandId = msg.getHeader().getCommandId();
if (packetType.getCommandId() != commandId) {
// 不解析,交给下一个codec
out.add(msg);
return;
}
CmppSubmitResponseMessage responseMessage = new CmppSubmitResponseMessage(msg.getHeader());
ByteBuf bodyBuffer = Unpooled.wrappedBuffer(msg.getBodyBuffer());
responseMessage.setMsgId(DefaultMsgIdUtil.bytes2MsgId(toArray(bodyBuffer, CmppSubmitResponse.MSGID.getLength())));
responseMessage.setResult(bodyBuffer.readUnsignedInt());
ReferenceCountUtil.release(bodyBuffer);
out.add(responseMessage);
}
use of com.zx.sms.codec.cmpp.msg.CmppSubmitResponseMessage in project SMSGate by Lihuanghe.
the class Cmpp20SubmitResponseMessageCodec method decode.
@Override
protected void decode(ChannelHandlerContext ctx, Message msg, List<Object> out) throws Exception {
int commandId = msg.getHeader().getCommandId();
if (packetType.getCommandId() != commandId) {
// 不解析,交给下一个codec
out.add(msg);
return;
}
CmppSubmitResponseMessage responseMessage = new CmppSubmitResponseMessage(msg.getHeader());
ByteBuf bodyBuffer = Unpooled.wrappedBuffer(msg.getBodyBuffer());
responseMessage.setMsgId(DefaultMsgIdUtil.bytes2MsgId(toArray(bodyBuffer, Cmpp20SubmitResponse.MSGID.getLength())));
responseMessage.setResult(bodyBuffer.readUnsignedByte());
ReferenceCountUtil.release(bodyBuffer);
out.add(responseMessage);
}
use of com.zx.sms.codec.cmpp.msg.CmppSubmitResponseMessage in project SMSGate by Lihuanghe.
the class TestCmpp20SubmitResponseMessageCodec method testCode.
@Test
public void testCode() {
CmppSubmitResponseMessage msg = new CmppSubmitResponseMessage(238);
msg.setMsgId(new MsgId());
msg.setResult(3413);
ByteBuf buf = encode(msg);
ByteBuf copybuf = buf.copy();
int length = buf.readableBytes();
int expectLength = Cmpp20SubmitResponse.MSGID.getBodyLength() + CmppHead.COMMANDID.getHeadLength();
Assert.assertEquals(expectLength, length);
Assert.assertEquals(expectLength, buf.readInt());
Assert.assertEquals(msg.getPacketType().getCommandId(), buf.readInt());
Assert.assertEquals(msg.getHeader().getSequenceId(), buf.readInt());
CmppSubmitResponseMessage result = decode(copybuf);
Assert.assertEquals(msg.getHeader().getSequenceId(), result.getHeader().getSequenceId());
Assert.assertEquals(msg.getMsgId(), result.getMsgId());
Assert.assertEquals(msg.getResult() & 0xff, result.getResult());
}
use of com.zx.sms.codec.cmpp.msg.CmppSubmitResponseMessage in project SMSGate by Lihuanghe.
the class TestCmppSubmitResponseMessageCodec method testCode.
@Test
public void testCode() {
CmppSubmitResponseMessage msg = new CmppSubmitResponseMessage(238);
msg.setMsgId(new MsgId());
msg.setResult(3413 & 0xff);
ByteBuf buf = encode(msg);
ByteBuf copybuf = buf.copy();
int length = buf.readableBytes();
int expectLength = (getVersion() == 0x30 ? CmppSubmitResponse.MSGID.getBodyLength() : Cmpp20SubmitResponse.MSGID.getBodyLength()) + CmppHead.COMMANDID.getHeadLength();
Assert.assertEquals(expectLength, length);
Assert.assertEquals(expectLength, buf.readInt());
Assert.assertEquals(msg.getPacketType().getCommandId(), buf.readInt());
Assert.assertEquals(msg.getHeader().getSequenceId(), buf.readInt());
CmppSubmitResponseMessage result = decode(copybuf);
Assert.assertEquals(msg.getHeader().getSequenceId(), result.getHeader().getSequenceId());
Assert.assertEquals(msg.getMsgId(), result.getMsgId());
Assert.assertEquals(msg.getResult(), result.getResult());
}
use of com.zx.sms.codec.cmpp.msg.CmppSubmitResponseMessage in project SMSGate by Lihuanghe.
the class CMPPSubmitLongMessageHandler method response.
@Override
protected BaseMessage response(CmppSubmitRequestMessage msg) {
// 短信片断未接收完全,直接给网关回复resp,等待其它片断
CmppSubmitResponseMessage responseMessage = new CmppSubmitResponseMessage(msg.getHeader());
responseMessage.setResult(0);
return responseMessage;
}
Aggregations