/**
   * Add a SIP session in the list
   *
   * @param session SIP session
   */
  protected static void addSipSession(MultimediaSessionImpl session) {
    if (logger.isActivated()) {
      logger.debug("Add a multimedia session in the list (size=" + sipSessions.size() + ")");
    }

    sipSessions.put(session.getSessionId(), session);
  }
  /**
   * Initiates a new multimedia session for real time messaging with a remote contact and for a
   * given service. The messages exchanged in real time during the session may be from any type. The
   * parameter contact supports the following formats: MSISDN in national or international format,
   * SIP address, SIP-URI or Tel-URI. If the format of the contact is not supported an exception is
   * thrown.
   *
   * @param serviceId Service ID
   * @param contact Contact
   * @param listener Multimedia session event listener
   * @return Multimedia session
   * @throws ServerApiException
   */
  public IMultimediaSession initiateSession(
      String serviceId, String contact, IMultimediaSessionListener listener)
      throws ServerApiException {
    if (logger.isActivated()) {
      logger.info("Initiate a multimedia session with " + contact);
    }

    // Test IMS connection
    ServerApiUtils.testIms();

    try {
      // Initiate a new session
      String featureTag =
          FeatureTags.FEATURE_RCSE
              + "=\""
              + FeatureTags.FEATURE_RCSE_EXTENSION
              + "."
              + serviceId
              + "\"";
      final GenericSipSession session =
          Core.getInstance().getSipService().initiateSession(contact, featureTag);

      // Add session listener
      MultimediaSessionImpl sessionApi = new MultimediaSessionImpl(session);
      sessionApi.addEventListener(listener);

      // Start the session
      Thread t =
          new Thread() {
            public void run() {
              session.startSession();
            }
          };
      t.start();

      // Add session in the list
      MultimediaSessionServiceImpl.addSipSession(sessionApi);
      return sessionApi;
    } catch (Exception e) {
      if (logger.isActivated()) {
        logger.error("Unexpected error", e);
      }
      throw new ServerApiException(e.getMessage());
    }
  }