package com.notnoop.apns.internal.netty;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.notnoop.apns.DeliveryResult;

public class ApnsHandler extends SimpleChannelInboundHandler<DeliveryResult> {

    private static final Logger LOGGER = LoggerFactory
            .getLogger(ApnsHandler.class);

    private final DeliveryResultListener listener;

    public ApnsHandler(DeliveryResultListener listener) {
        super(DeliveryResult.class);
        this.listener = listener;
    }

    @Override
    public void channelRead0(ChannelHandlerContext ctx, DeliveryResult msg)
            throws Exception {
        LOGGER.debug("Received message: {}", msg);
        listener.onDeliveryResult(ctx, msg);
    }

}

@@ -824,12 +824,236 @@
 );%0A    %7D
+%0A    %0A    @Override%0A    public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause)%0A            throws Exception %7B%0A    %09LOGGER.info(%22Exception while listening for result: %22 + cause.getMessage(),%0A%09%09%09%09cause);%0A    %7D
 %0A%0A%7D%0A

Handle exception in pipeline