Search in sources :

Example 1 with SgipUnbindResponseMessage

use of com.zx.sms.codec.sgip12.msg.SgipUnbindResponseMessage in project SMSGate by Lihuanghe.

the class SgipUnbindRequestMessageHandler method channelRead0.

@Override
protected void channelRead0(final ChannelHandlerContext ctx, SgipUnbindRequestMessage msg) throws Exception {
    SgipUnbindResponseMessage resp = new SgipUnbindResponseMessage(msg.getHeader());
    ChannelFuture future = ctx.channel().writeAndFlush(resp);
    final ChannelHandlerContext finalctx = ctx;
    future.addListeners(new GenericFutureListener() {

        @Override
        public void operationComplete(Future future) throws Exception {
            ctx.executor().schedule(new Runnable() {

                @Override
                public void run() {
                    finalctx.channel().close();
                }
            }, 500, TimeUnit.MILLISECONDS);
        }
    });
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) Future(io.netty.util.concurrent.Future) ChannelFuture(io.netty.channel.ChannelFuture) ChannelHandlerContext(io.netty.channel.ChannelHandlerContext) GenericFutureListener(io.netty.util.concurrent.GenericFutureListener) SgipUnbindResponseMessage(com.zx.sms.codec.sgip12.msg.SgipUnbindResponseMessage)

Example 2 with SgipUnbindResponseMessage

use of com.zx.sms.codec.sgip12.msg.SgipUnbindResponseMessage in project SMSGate by Lihuanghe.

the class SgipUnbindResponseMessageCodec 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;
    }
    SgipUnbindResponseMessage responseMessage = new SgipUnbindResponseMessage(msg.getHeader());
    responseMessage.setTimestamp(msg.getTimestamp());
    out.add(responseMessage);
}
Also used : SgipUnbindResponseMessage(com.zx.sms.codec.sgip12.msg.SgipUnbindResponseMessage)

Aggregations

SgipUnbindResponseMessage (com.zx.sms.codec.sgip12.msg.SgipUnbindResponseMessage)2 ChannelFuture (io.netty.channel.ChannelFuture)1 ChannelHandlerContext (io.netty.channel.ChannelHandlerContext)1 Future (io.netty.util.concurrent.Future)1 GenericFutureListener (io.netty.util.concurrent.GenericFutureListener)1