private static String getRemoteSipId(ChatSession session) {
   ContactHeader inviteContactHeader =
       (ContactHeader) session.getDialogPath().getInvite().getHeader(ContactHeader.NAME);
   if (inviteContactHeader == null) {
     return null;
   }
   return inviteContactHeader.getParameter(SipUtils.SIP_INSTANCE_PARAM);
 }
Beispiel #2
0
  /**
   * Handle 200 0K response
   *
   * @param resp 200 OK response
   */
  public void handle200OK(SipResponse resp) {
    try {
      // 200 OK received
      if (logger.isActivated()) {
        logger.info("200 OK response received");
      }

      // The signaling is established
      getDialogPath().sigEstablished();

      // Set the remote tag
      getDialogPath().setRemoteTag(resp.getToTag());

      // Set the target
      getDialogPath().setTarget(resp.getContactURI());

      // Set the route path with the Record-Route header
      Vector<String> newRoute = SipUtils.routeProcessing(resp, true);
      getDialogPath().setRoute(newRoute);

      // Set the remote SDP part
      getDialogPath().setRemoteContent(resp.getContent());

      Capabilities capabilities = CapabilityUtils.extractCapabilities(resp);
      if (capabilities != null && this instanceof GroupChatSession) {
        ((GroupChatSession) this).setMsrpFtSupport(capabilities.isFileTransferSupported());
      }

      // Set the remote SIP instance ID
      ContactHeader remoteContactHeader = (ContactHeader) resp.getHeader(ContactHeader.NAME);
      if (remoteContactHeader != null) {
        getDialogPath()
            .setRemoteSipInstance(remoteContactHeader.getParameter(SipUtils.SIP_INSTANCE_PARAM));
      }

      // Prepare Media Session
      prepareMediaSession();

      // Send ACK request
      if (logger.isActivated()) {
        logger.info("Send ACK");
      }
      getImsService().getImsModule().getSipManager().sendSipAck(getDialogPath());

      // The session is established
      getDialogPath().sessionEstablished();

      // Start Media Session
      startMediaSession();

      // Notify listeners
      for (int i = 0; i < getListeners().size(); i++) {
        getListeners().get(i).handleSessionStarted();
      }

      // Start session timer
      if (getSessionTimerManager().isSessionTimerActivated(resp)) {
        getSessionTimerManager()
            .start(resp.getSessionTimerRefresher(), resp.getSessionTimerExpire());
      }
    } catch (Exception e) {
      // Unexpected error
      if (logger.isActivated()) {
        logger.error("Session initiation has failed", e);
      }
      handleError(new ImsServiceError(ImsServiceError.UNEXPECTED_EXCEPTION, e.getMessage()));
    }
  }