コード例 #1
0
  // -------------------------------------------------------------------------
  private S2SConnector getS2SConnector(String hostname) throws Exception {
    S2SConnector s2s = null;

    synchronized (hostnameAndS2SMap) {
      s2s = hostnameAndS2SMap.get(hostname);

      if (s2s != null && !s2s.isAlive()) {
        defaultNeximLogger.info("Removing s2s for hostname (thread not alive) " + hostname);
        hostnameAndS2SMap.remove(hostname);
        s2s = null;
      }

      if (s2s == null || s2s.getSession().isClosed()) {
        s2s = s2sConnectorFactory.createS2SConnector();
        s2s.setIMConnectionHandler(connectionHandler);
        s2s.setRouter(router);
        s2s.setSessionsManager(sessionsManager);
        s2s.setToHostname(hostname);
        new Thread(s2s).start();
        hostnameAndS2SMap.put(hostname, s2s);
      }
    }

    return s2s;
  }
コード例 #2
0
  // ----------------------------------------------------------------------
  public IMServerSession getRemoteSessionWaitForValidation(String hostname, long timeout)
      throws Exception {
    IMServerSession session = null;
    S2SConnector s2s = null;

    synchronized (hostnameAndS2SMap) {
      s2s = (S2SConnector) hostnameAndS2SMap.get(hostname);

      if (s2s != null && !s2s.getSession().isClosed()) {
        session = s2s.getSession();
      } else {
        s2s = getS2SConnector(hostname);
        session = s2s.getSession();
      }
    }

    synchronized (session) {
      // wait for validation
      if (!session.getDialbackValid()) {
        s2s.sendResult();
        defaultNeximLogger.info("Wait validation for " + hostname + " for session " + session);
        session.wait(timeout);
      }
    }

    if (!session.getDialbackValid()) {
      throw new Exception(
          "Unable to get dialback validation for "
              + hostname
              + " after timeout "
              + timeout
              + " ms");
    }

    defaultNeximLogger.info("Validation granted from " + hostname + " for session " + session);

    return session;
  } // getremote session