コード例 #1
0
ファイル: InviteHandler.java プロジェクト: biddyweb/peers
 public void errResponseReceived(final SipResponse sipResponse) {
   Dialog dialog = dialogManager.getDialog(sipResponse);
   if (dialog != null) {
     dialog.receivedOrSent300To699();
     dialogManager.removeDialog(dialog.getId());
   }
   int statusCode = sipResponse.getStatusCode();
   if (statusCode == RFC3261.CODE_401_UNAUTHORIZED
       || statusCode == RFC3261.CODE_407_PROXY_AUTHENTICATION_REQUIRED && !challenged) {
     InviteClientTransaction inviteClientTransaction =
         (InviteClientTransaction) transactionManager.getClientTransaction(sipResponse);
     SipRequest sipRequest = inviteClientTransaction.getRequest();
     String password = userAgent.getConfig().getPassword();
     if (password != null && !"".equals(password.trim())) {
       challengeManager.handleChallenge(sipRequest, sipResponse);
     }
     challenged = true;
     return;
   } else {
     challenged = false;
   }
   SipListener sipListener = userAgent.getSipListener();
   if (sipListener != null) {
     sipListener.error(sipResponse);
   }
   List<String> guiClosedCallIds = userAgent.getUac().getGuiClosedCallIds();
   String callId = Utils.getMessageCallId(sipResponse);
   if (guiClosedCallIds.contains(callId)) {
     guiClosedCallIds.remove(callId);
   }
   userAgent.getMediaManager().setDatagramSocket(null);
 }
コード例 #2
0
 public void terminate(SipRequest sipRequest) {
   String callId = Utils.getMessageCallId(sipRequest);
   if (!guiClosedCallIds.contains(callId)) {
     guiClosedCallIds.add(callId);
   }
   Dialog dialog = dialogManager.getDialog(callId);
   SipRequest inviteWithAuth = getInviteWithAuth(callId);
   if (dialog != null) {
     SipRequest originatingRequest;
     if (inviteWithAuth != null) {
       originatingRequest = inviteWithAuth;
     } else {
       originatingRequest = sipRequest;
     }
     ClientTransaction clientTransaction =
         transactionManager.getClientTransaction(originatingRequest);
     if (clientTransaction != null) {
       synchronized (clientTransaction) {
         DialogState dialogState = dialog.getState();
         if (dialog.EARLY.equals(dialogState)) {
           initialRequestManager.createCancel(inviteWithAuth, midDialogRequestManager, profileUri);
         } else if (dialog.CONFIRMED.equals(dialogState)) {
           // clientTransaction not yet removed
           midDialogRequestManager.generateMidDialogRequest(dialog, RFC3261.METHOD_BYE, null);
           guiClosedCallIds.remove(callId);
         }
       }
     } else {
       // clientTransaction Terminated and removed
       logger.debug("clientTransaction null");
       midDialogRequestManager.generateMidDialogRequest(dialog, RFC3261.METHOD_BYE, null);
       guiClosedCallIds.remove(callId);
     }
   } else {
     InviteClientTransaction inviteClientTransaction =
         (InviteClientTransaction) transactionManager.getClientTransaction(inviteWithAuth);
     if (inviteClientTransaction == null) {
       logger.error("cannot find invite client transaction" + " for call " + callId);
     } else {
       SipResponse sipResponse = inviteClientTransaction.getLastResponse();
       if (sipResponse != null) {
         int statusCode = sipResponse.getStatusCode();
         if (statusCode < RFC3261.CODE_200_OK) {
           initialRequestManager.createCancel(inviteWithAuth, midDialogRequestManager, profileUri);
         }
       }
     }
   }
   switch (userAgent.getMediaMode()) {
     case captureAndPlayback:
       userAgent.getMediaManager().stopSession();
       SoundManager soundManager = userAgent.getSoundManager();
       if (soundManager != null) {
         soundManager.closeLines();
       }
       break;
     case echo:
       Echo echo = userAgent.getEcho();
       if (echo != null) {
         echo.stop();
         userAgent.setEcho(null);
       }
       break;
     case file:
       MediaManager mediaManager = userAgent.getMediaManager();
       mediaManager.stopSession();
       break;
     default:
       break;
   }
 }