コード例 #1
0
 public void shutdown() {
   retries = -1;
   if (channel != null) {
     try {
       channel.disconnect();
       channel.close();
     } catch (Throwable e) {
       Flog.error(e);
     }
     channel = null;
   }
 }
コード例 #2
0
  protected void connect() {
    if (retries <= 0) {
      Flog.error("I give up connecting.");
      return;
    }
    retries -= 1;
    FlooUrl flooUrl = handler.getUrl();
    final String host;
    final int port;

    if (flooUrl.host.equals(Constants.floobitsDomain) && retries % 4 == 0) {
      host = Constants.OUTBOUND_FILTER_PROXY_HOST;
      port = Constants.OUTBOUND_FILTER_PROXY_PORT;
    } else {
      host = flooUrl.host;
      port = flooUrl.port;
    }

    if (channel == null) {
      _connect(host, port);
      return;
    }
    try {
      channel
          .close()
          .addListener(
              new ChannelFutureListener() {
                @Override
                public void operationComplete(ChannelFuture channelFuture) throws Exception {
                  channel = null;
                  _connect(host, port);
                }
              });
    } catch (Throwable e) {
      Flog.error(e);
      reconnect();
    }
  }