// Path: src/com/netty/push/sdk/client/listener/INettyClientHandlerListener.java
// public interface INettyClientHandlerListener {
// 	public void receive(MessageResult messageResult);
// }
// 
// Path: src/com/netty/push/sdk/pojo/Message.java
// public class Message implements Serializable {
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 8882696265942622650L;
// 	private String appKey;
// 	private String title;
// 	private String content;
// 	private boolean isOfflineShow;
// 	// 是否需要回执
// 	private boolean isReceipt;
// 
// 	private boolean isAllPush;
// 	private List<String> devices;
// 
// 	public String getAppKey() {
// 		return appKey;
// 	}
// 
// 	public void setAppKey(String appKey) {
// 		this.appKey = appKey;
// 	}
// 
// 	public String getTitle() {
// 		return title;
// 	}
// 
// 	public void setTitle(String title) {
// 		this.title = title;
// 	}
// 
// 	public String getContent() {
// 		return content;
// 	}
// 
// 	public void setContent(String content) {
// 		this.content = content;
// 	}
// 
// 	public boolean isOfflineShow() {
// 		return isOfflineShow;
// 	}
// 
// 	public void setOfflineShow(boolean isOfflineShow) {
// 		this.isOfflineShow = isOfflineShow;
// 	}
// 
// 	public boolean isReceipt() {
// 		return isReceipt;
// 	}
// 
// 	public void setReceipt(boolean isReceipt) {
// 		this.isReceipt = isReceipt;
// 	}
// 
// 	public List<String> getDevices() {
// 		return devices;
// 	}
// 
// 	public void setDevices(List<String> devices) {
// 		this.devices = devices;
// 	}
// 
// 	public boolean isAllPush() {
// 		return isAllPush;
// 	}
// 
// 	public void setAllPush(boolean isAllPush) {
// 		this.isAllPush = isAllPush;
// 	}
// 
// }


import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import io.netty.handler.codec.serialization.ClassResolvers;
import io.netty.handler.codec.serialization.ObjectDecoder;
import io.netty.handler.codec.serialization.ObjectEncoder;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import com.netty.push.sdk.client.listener.INettyClientHandlerListener;
import com.netty.push.sdk.pojo.Message;
	public void setCtx(ChannelHandlerContext ctx) {
		this.ctx = ctx;
	}

	/**
	 * 类级的内部类，也就是静态的成员式内部类，该内部类的实例与外部类的实例 没有绑定关系，而且只有被调用到时才会装载，从而实现了延迟加载。
	 */
	private static class SingletonHolder {
		/**
		 * 静态初始化器，由JVM来保证线程安全
		 */
		private static NettyClient instance = new NettyClient();
	}

	public static NettyClient getInstance(final String host, final int port) {
		if (nettyClient == null) {
			nettyClient = SingletonHolder.instance;
			nettyClient.host = host;
			nettyClient.port = port;
		}
		return nettyClient;
	}

	/**
	 * 连接方法
	 * 
	 * @param host
	 * @param port
	 * @throws Exception
	 */
// Path: src/com/netty/push/sdk/client/listener/INettyClientHandlerListener.java
// public interface INettyClientHandlerListener {
// 	public void receive(MessageResult messageResult);
// }
// 
// Path: src/com/netty/push/sdk/pojo/Message.java
// public class Message implements Serializable {
// 	/**
// 	 * 
// 	 */
// 	private static final long serialVersionUID = 8882696265942622650L;
// 	private String appKey;
// 	private String title;
// 	private String content;
// 	private boolean isOfflineShow;
// 	// 是否需要回执
// 	private boolean isReceipt;
// 
// 	private boolean isAllPush;
// 	private List<String> devices;
// 
// 	public String getAppKey() {
// 		return appKey;
// 	}
// 
// 	public void setAppKey(String appKey) {
// 		this.appKey = appKey;
// 	}
// 
// 	public String getTitle() {
// 		return title;
// 	}
// 
// 	public void setTitle(String title) {
// 		this.title = title;
// 	}
// 
// 	public String getContent() {
// 		return content;
// 	}
// 
// 	public void setContent(String content) {
// 		this.content = content;
// 	}
// 
// 	public boolean isOfflineShow() {
// 		return isOfflineShow;
// 	}
// 
// 	public void setOfflineShow(boolean isOfflineShow) {
// 		this.isOfflineShow = isOfflineShow;
// 	}
// 
// 	public boolean isReceipt() {
// 		return isReceipt;
// 	}
// 
// 	public void setReceipt(boolean isReceipt) {
// 		this.isReceipt = isReceipt;
// 	}
// 
// 	public List<String> getDevices() {
// 		return devices;
// 	}
// 
// 	public void setDevices(List<String> devices) {
// 		this.devices = devices;
// 	}
// 
// 	public boolean isAllPush() {
// 		return isAllPush;
// 	}
// 
// 	public void setAllPush(boolean isAllPush) {
// 		this.isAllPush = isAllPush;
// 	}
// 
// }


// Path: src/com/netty/push/sdk/client/NettyClient.java
import io.netty.bootstrap.Bootstrap;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioSocketChannel;
import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.LengthFieldPrepender;
import io.netty.handler.codec.serialization.ClassResolvers;
import io.netty.handler.codec.serialization.ObjectDecoder;
import io.netty.handler.codec.serialization.ObjectEncoder;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
import com.netty.push.sdk.client.listener.INettyClientHandlerListener;
import com.netty.push.sdk.pojo.Message;

	public void setCtx(ChannelHandlerContext ctx) {
		this.ctx = ctx;
	}

	/**
	 * 类级的内部类，也就是静态的成员式内部类，该内部类的实例与外部类的实例 没有绑定关系，而且只有被调用到时才会装载，从而实现了延迟加载。
	 */
	private static class SingletonHolder {
		/**
		 * 静态初始化器，由JVM来保证线程安全
		 */
		private static NettyClient instance = new NettyClient();
	}

	public static NettyClient getInstance(final String host, final int port) {
		if (nettyClient == null) {
			nettyClient = SingletonHolder.instance;
			nettyClient.host = host;
			nettyClient.port = port;
		}
		return nettyClient;
	}

	/**
	 * 连接方法
	 * 
	 * @param host
	 * @param port
	 * @throws Exception
	 */
	public void sendMessage(final Message message, final INettyClientHandlerListener listener) throws Exception {