/** Terminate session */ public void terminateSessionWithoutBy() { if (dialogPath.isSessionTerminated()) { // Already terminated return; } // Stop session timer getSessionTimerManager().stop(); // Update dialog path dialogPath.sessionTerminated(); // Unblock semaphore (used for terminating side only) synchronized (waitUserAnswer) { waitUserAnswer.notifyAll(); } }
/** Terminate session */ public void terminateSession() { if (logger.isActivated()) { logger.debug("Terminate the session"); } if (dialogPath.isSessionTerminated()) { // Already terminated return; } // Stop session timer getSessionTimerManager().stop(); // Update dialog path dialogPath.sessionTerminated(); // Unblock semaphore (used for terminating side only) synchronized (waitUserAnswer) { waitUserAnswer.notifyAll(); } try { // Terminate the session if (dialogPath.isSigEstablished()) { // Increment the Cseq number of the dialog path getDialogPath().incrementCseq(); // Send BYE without waiting a response getImsService().getImsModule().getSipManager().sendSipBye(getDialogPath()); } else { // Send CANCEL without waiting a response getImsService().getImsModule().getSipManager().sendSipCancel(getDialogPath()); } if (logger.isActivated()) { logger.debug("SIP session has been terminated"); } } catch (Exception e) { if (logger.isActivated()) { logger.error("Session termination has failed", e); } } }
/** * Terminate session * * @param reason Reason */ public void terminateSession(int reason) { if (logger.isActivated()) { logger.debug("Terminate the session (reason " + reason + ")"); } if ((dialogPath == null) || dialogPath.isSessionTerminated()) { // Already terminated return; } // Stop session timer getSessionTimerManager().stop(); // Update dialog path if (reason == ImsServiceSession.TERMINATION_BY_USER) { dialogPath.sessionTerminated(200, "Call completed"); } else { dialogPath.sessionTerminated(); } // Unblock semaphore (used for terminating side only) synchronized (waitUserAnswer) { waitUserAnswer.notifyAll(); } try { // Terminate the session if (dialogPath.isSigEstablished()) { // Increment the Cseq number of the dialog path getDialogPath().incrementCseq(); // Send BYE without waiting a response getImsService().getImsModule().getSipManager().sendSipBye(getDialogPath()); } else { // Send CANCEL without waiting a response getImsService().getImsModule().getSipManager().sendSipCancel(getDialogPath()); } if (logger.isActivated()) { logger.debug("SIP session has been terminated"); } } catch (Exception e) { if (logger.isActivated()) { logger.error("Session termination has failed", e); } } if (this.getDialogPath().isSigEstablished() && reason != ImsServiceSession.TERMINATION_BY_USER) { for (int j = 0; j < getListeners().size(); j++) { final ImsSessionListener listener = getListeners().get(j); if (listener instanceof FileSharingSessionListener) { AsyncTask.execute( new Runnable() { @Override public void run() { try { Thread.sleep(3 * 1000); } catch (InterruptedException e) { // Nothing to do } ((FileSharingSessionListener) listener) .handleTransferError( new FileSharingError(FileSharingError.MEDIA_TRANSFER_FAILED)); } }); } } } }