public void connect() {
   ConnectFuture connectFuture = connector.connect(new InetSocketAddress(host, port), this);
   connectFuture.join(5000);
   try {
     session = connectFuture.getSession();
   } catch (RuntimeIOException e) {
     engine.error(e);
   }
 }
  public void sendRequest(String request) {
    if (session == null) {
      engine.error("not connected");
    } else {
      session.write(request);

      synchronized (engine) {
        try {
          engine.wait(30000);
        } catch (InterruptedException e) {
          // ignore
        }
      }
    }
  }
 public void exceptionCaught(IoSession session, Throwable cause) throws Exception {
   engine.error(cause);
 }