use of com.zx.sms.codec.sgip12.msg.SgipSubmitResponseMessage in project SMSGate by Lihuanghe.
the class SGIPMessageReceiveHandler method reponse.
@Override
protected ChannelFuture reponse(final ChannelHandlerContext ctx, Object msg) {
if (msg instanceof SgipDeliverRequestMessage) {
SgipDeliverRequestMessage deli = (SgipDeliverRequestMessage) msg;
SgipDeliverResponseMessage resp = new SgipDeliverResponseMessage(deli.getHeader());
resp.setResult((short) 0);
resp.setTimestamp(deli.getTimestamp());
List<SgipDeliverRequestMessage> deliarr = deli.getFragments();
if (deliarr != null) {
for (SgipDeliverRequestMessage item : deliarr) {
SgipDeliverResponseMessage item_resp = new SgipDeliverResponseMessage(item.getHeader());
item_resp.setResult((short) 0);
item_resp.setTimestamp(item.getTimestamp());
ctx.writeAndFlush(item_resp);
}
}
return ctx.writeAndFlush(resp);
} else if (msg instanceof SgipSubmitRequestMessage) {
SgipSubmitRequestMessage submit = (SgipSubmitRequestMessage) msg;
SgipSubmitResponseMessage resp = new SgipSubmitResponseMessage(submit.getHeader());
resp.setTimestamp(submit.getTimestamp());
resp.setResult((short) 0);
boolean sendreport = 1 == submit.getReportflag();
List<SgipSubmitRequestMessage> deliarr = submit.getFragments();
if (deliarr != null) {
for (SgipSubmitRequestMessage item : deliarr) {
SgipSubmitResponseMessage item_resp = new SgipSubmitResponseMessage(item.getHeader());
item_resp.setResult((short) 0);
item_resp.setTimestamp(item.getTimestamp());
ctx.writeAndFlush(item_resp);
if (sendreport) {
SgipReportRequestMessage report = new SgipReportRequestMessage();
report.setSequenceId(item_resp.getSequenceNumber());
ctx.writeAndFlush(report);
}
}
}
ChannelFuture future = ctx.writeAndFlush(resp);
if (sendreport) {
SgipReportRequestMessage report = new SgipReportRequestMessage();
report.setSequenceId(resp.getSequenceNumber());
ctx.writeAndFlush(report);
}
return future;
}
return null;
}
use of com.zx.sms.codec.sgip12.msg.SgipSubmitResponseMessage in project SMSGate by Lihuanghe.
the class SgipSubmitResponseMessageCodec 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;
}
SgipSubmitResponseMessage responseMessage = new SgipSubmitResponseMessage(msg.getHeader());
responseMessage.setTimestamp(msg.getTimestamp());
ByteBuf bodyBuffer = Unpooled.wrappedBuffer(msg.getBodyBuffer());
responseMessage.setResult(bodyBuffer.readUnsignedByte());
responseMessage.setReserve(bodyBuffer.readCharSequence(SgipSubmitResponse.RESERVE.getLength(), GlobalConstance.defaultTransportCharset).toString().trim());
ReferenceCountUtil.release(bodyBuffer);
out.add(responseMessage);
}
Aggregations