Пример #1
0
  /**
   * Calls shutdown on current state and waits until a finished state is reached.
   *
   * @throws InterruptedException if the waiting for a finished state is interrupted.
   */
  public void shutdown() throws InterruptedException {
    stateLock.lock();
    try {
      isShutdown = true;

      // interrupts any take operations
      takeCallLock.lock();
      try {
        takeCallCondition.signalAll();
      } finally {
        takeCallLock.unlock();
      }

      currentServerState.shutdown();
      while (true) {
        if (currentServerState.getCurrentState() == ServerStates.Finished) {
          break;
        }
        if (currentServerState.getCurrentState() == ServerStates.Error) {
          break;
        }
        stateChangeCondition.await();
      }
      callMapCleanupTimer.cancel();
      callMapCleanupTask.cancel();
      stateTimeoutTimer.cancel();
    } catch (InterruptedException e) {
      throw e;
    } finally {
      stateLock.unlock();
    }
  }
Пример #2
0
 public void onFailure(final ErrorMessage eMessage) {
   stateLock.lock();
   try {
     currentServerState.onFailure(eMessage);
   } finally {
     stateLock.unlock();
   }
 }
Пример #3
0
 public void onTimeOut() {
   stateLock.lock();
   try {
     currentServerState.onTimeOut();
   } finally {
     stateLock.unlock();
   }
 }
Пример #4
0
 public void onBye(final IMessage message) {
   stateLock.lock();
   try {
     currentServerState.onBye(message);
   } finally {
     stateLock.unlock();
   }
 }
Пример #5
0
 public void onInvite(final IMessage inviteMessage) {
   stateLock.lock();
   try {
     currentServerState.onInvite(inviteMessage);
   } finally {
     stateLock.unlock();
   }
 }
Пример #6
0
 private UCESipServerCall pollCall() {
   LOGGER.trace("takeCall stateLock.lock() before");
   stateLock.lock();
   try {
     LOGGER.trace("takeCall stateLock.lock() after");
     return currentServerState.pollCall();
   } finally {
     stateLock.unlock();
   }
 }
Пример #7
0
 /** Call only with state lock, from state itself it should have the lock already */
 @Override
 public void changeState(final IServerState newState) {
   if (currentServerState.equals(newState) == false) {
     // reset state timeout timer.
     if (currentStateTimeoutTask != null) {
       currentStateTimeoutTask.cancel();
       currentStateTimeoutTask = null;
     }
     // check if the new state wants a timeout timer, and how long the
     // timeout shall be
     if (newState.getStateTimeoutMillis() != 0) {
       currentStateTimeoutTask = new StateTimeoutTask();
       stateTimeoutTimer.schedule(currentStateTimeoutTask, newState.getStateTimeoutMillis());
     }
     currentServerState = newState;
     LOGGER.trace("sip server changed state to " + newState.getCurrentState().toString());
     currentServerState.onInit();
     stateChangeCondition.signalAll();
   }
 }
Пример #8
0
 public void register() throws UCESipException, InterruptedException {
   stateLock.lock();
   try {
     currentServerState.startRegister();
     while (true) {
       if (currentServerState.getCurrentState() == ServerStates.Registered) {
         break;
       }
       if (currentServerState.getCurrentState() == ServerStates.Error) {
         // check for asynchronous error
         throw ((ErrorServerState) currentServerState).getError();
       }
       stateChangeCondition.await();
     }
     long tp = sipSettings.getServerCallMapCleanupPeriodMillis();
     callMapCleanupTimer.scheduleAtFixedRate(callMapCleanupTask, tp, tp);
   } catch (InterruptedException e) {
     throw e;
   } finally {
     stateLock.unlock();
   }
 }