use of com.zx.sms.codec.sgip12.msg.SgipBindResponseMessage in project SMSGate by Lihuanghe.
the class SgipBindResponseMessageCodec 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;
}
SgipBindResponseMessage responseMessage = new SgipBindResponseMessage(msg.getHeader());
responseMessage.setTimestamp(msg.getTimestamp());
ByteBuf bodyBuffer = Unpooled.wrappedBuffer(msg.getBodyBuffer());
responseMessage.setResult(bodyBuffer.readUnsignedByte());
responseMessage.setReserve(bodyBuffer.readCharSequence(SgipBindResponse.RESERVE.getLength(), GlobalConstance.defaultTransportCharset).toString().trim());
ReferenceCountUtil.release(bodyBuffer);
out.add(responseMessage);
}
use of com.zx.sms.codec.sgip12.msg.SgipBindResponseMessage in project SMSGate by Lihuanghe.
the class SgipSessionLoginManager method doLoginSuccess.
@Override
protected void doLoginSuccess(ChannelHandlerContext ctx, EndpointEntity entity, Object message) {
// 发送bind请求
SgipEndpointEntity sgipentity = (SgipEndpointEntity) entity;
SgipBindResponseMessage resp = new SgipBindResponseMessage(((Message) message).getHeader());
resp.setResult((short) 0);
resp.setTimestamp(((Message) message).getTimestamp());
ctx.channel().writeAndFlush(resp);
}
use of com.zx.sms.codec.sgip12.msg.SgipBindResponseMessage in project SMSGate by Lihuanghe.
the class SgipSessionLoginManager method failedLogin.
@Override
protected void failedLogin(ChannelHandlerContext ctx, Object msg, long status) {
if (msg instanceof SgipBindRequestMessage) {
logger.error("Connected error status :{},msg : {}", status, msg);
SgipBindRequestMessage message = (SgipBindRequestMessage) msg;
// 认证失败
SgipBindResponseMessage resp = new SgipBindResponseMessage(((Message) message).getHeader());
resp.setResult((short) status);
resp.setTimestamp(((Message) message).getTimestamp());
ChannelFuture promise = ctx.writeAndFlush(resp);
final ChannelHandlerContext finalctx = ctx;
promise.addListener(new GenericFutureListener() {
public void operationComplete(Future future) throws Exception {
finalctx.close();
}
});
} else {
logger.error("connect msg type error : {}", msg);
ctx.close();
}
}
Aggregations