public Connector(
      SocketAddress remoteAddress,
      TimeProperty autoReconnectInterval,
      MessageEncodingProtocol messageEncodingProtocol) {
    this.remoteAddress = remoteAddress;
    loopGroup =
        new MessageQueueLoopGroup(
            Executors.newCachedThreadPool(),
            messageHandler,
            new SingleMessageQueueStrategy(),
            new LoopShiftingStrategy());
    client = new NetLightClient(remoteAddress, getSslContext(), messageEncodingProtocol, loopGroup);
    if (autoReconnectInterval != null) {
      client.addChannelStateListener(
          new AutoReconnector(autoReconnectInterval.to(TimeUnit.MILLISECONDS)));
    }
    clientHandler =
        (ClientHandler)
            client.getChannelInitializer().getTcpChannelInitializer().getChannelHandler();
    serverSentMessageNotifier =
        new EventNotifier<>(
            new EventNotifierHandler<Message, ServerSentMessageListener>() {
              @Override
              public void handle(Message message, ServerSentMessageListener listener) {
                listener.onMessage(message);
              }

              @Override
              public void exceptionCaught(Throwable cause) {
                serverSentMessageNotifier.start();
              }
            },
            Message.class);
  }
 public boolean connect() {
   if (closed.get()) {
     throw new IllegalStateException("Connector closed");
   }
   return client.connect();
 }
 public void removeChannelStateListener(ChannelStateListener listener) {
   client.removeChannelStateListener(listener);
 }
 public void addChannelStateListener(ChannelStateListener listener) {
   client.addChannelStateListener(listener);
 }
 public boolean isConnected() {
   return client.isConnected();
 }
 public ChannelFuture closeFuture() {
   return client.closeFuture();
 }