Ejemplo n.º 1
0
  /**
   * This method closes the ServerPortal. The method is asynchronous: the ServerPortal will be
   * closed only when it receives event POTRTAL_CLOSED. If there are still ServerSessions on this
   * ServerPortal, they will be closed as well. Only after SESSION_CLOSED will be recieved on all
   * ServerSessions (if there are any), SERVER_PORTAL event will be received/.
   *
   * @return true if there was a successful call to close of the ServerPortal object on C side and
   *     false otherwise
   */
  public boolean close() {
    if (this.getIsClosing()) {
      LOG.warn(
          this.toLogString()
              + "attempting to close server portal that is already closed or being closed");
      return false;
    }
    if (getId() == 0) {
      LOG.error(this.toLogString() + "closing ServerPortal with empty id");
      return false;
    }
    for (ServerSession serverSession : sessions) {
      if (!serverSession.getIsClosing()) {
        if (LOG.isDebugEnabled()) {
          LOG.debug(
              this.toLogString()
                  + "closing serverSession="
                  + serverSession.getId()
                  + " from ServerPortal.close");
        }
        serverSession.close();
      }
    }

    Bridge.stopServerPortal(getId());
    setIsClosing(true);

    if (LOG.isDebugEnabled()) {
      LOG.debug(this.toLogString() + "close() Done");
    }
    return true;
  }
Ejemplo n.º 2
0
  /**
   * This method forwards the serverSession on the ServerPortal. This means that all ServerSession
   * events will arrive on this portal's EventQueueHandler.
   *
   * @param portal - the portal to which the serverSession will be forwarded
   * @param serverSession - sesrverSession that will be forwarded
   */
  public void forward(ServerPortal portal, ServerSession serverSession) {
    if (LOG.isDebugEnabled()) {
      LOG.debug(this.toLogString() + "portal " + portal + " ses id is " + serverSession.getId());
    }
    if (portal == this) { // in case forward was called but the user really means accept
      accept(serverSession);
      return;
    }
    URI uriForForward = portal.getUri();
    if (uriForForward.getHost().equals("0.0.0.0")) {
      uriForForward = this.replaceIPinURI(uriForForward, serverSession.getUri());
    }

    serverSession.setEventQueueHandlers(this.eqh, portal.eqh);
    if (!Bridge.forwardSession(uriForForward.toString(), serverSession.getId(), portal.getId()))
      LOG.error("forward failed");
    portal.setSession(serverSession);
  }
Ejemplo n.º 3
0
 /**
  * This method accepts the serverSession on this ServerPortal. This means that all ServerSession
  * events will arrive on this ServerPortal's EventQueueHandler.
  *
  * @param serverSession - serverSession that will be accepted
  */
 public void accept(ServerSession serverSession) {
   serverSession.setEventQueueHandlers(this.eqh, this.eqh);
   if (!Bridge.acceptSession(serverSession.getId(), this.getId())) LOG.error("accept failed");
   this.setSession(serverSession);
 }