Tabnine Logo
SipSession
Code IndexAdd Tabnine to your IDE (free)

How to use
SipSession
in
javax.servlet.sip

Best Java code snippets using javax.servlet.sip.SipSession (Showing top 20 results out of 315)

origin: org.mobicents.servlet.sip.examples/shopping-demo-business-jsr309

public void onEvent(PlayerEvent event) {
  try {
    logger.info("ENDING CALL ");
    Player player = event.getSource();
    MediaGroup mg = player.getContainer();
    if (event.isSuccessful()
        && (PlayerEvent.PLAY_COMPLETED == event.getEventType())) {
      MediaSession session =(MediaSession)sipSession.getAttribute("mediaSession");
      session.release();
      Thread.sleep(1500);
      
      SipServletRequest byeRequest = sipSession.createRequest("BYE");				
      byeRequest.send();
      
    }
  }
  catch (Exception e) {
    logger.error("Error", e);
  }
}
origin: org.mobicents.servlet.sip.examples/shopping-demo-business-jsr309

  public static void playFileInResponseToDTMFInfo(SipSession session,
      String audioFile) {
    logger.info("playing " + audioFile + " in response to DTMF");
    MediaGroup mg = (MediaGroup) session.getAttribute("mediaGroup");

    // Let us request for Announcement Complete event or Failure
    // in case if it happens

    try {
      mg.getPlayer().play(URI.create(audioFile), null, null);
    } catch (MsControlException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    session.setAttribute("DTMFSession", DTMFListener.DTMF_SESSION_STOPPED);
    logger.info("played " + audioFile + " in response to DTMF");
  }
}
origin: org.mobicents.servlet.sip/sip-servlets-impl

/**
 * Allows to override the System header modifiable rule assignment.
 * 
 * @return if the InitParameter is present at servletContext, or null
 * otherwise
 */
protected ModifiableRule retrieveModifiableOverriden() {
  ModifiableRule overridenRule = null;
  //use local var to prevent potential concurent cleanup
  SipSession session = getSession();
  if (session != null && session.getServletContext() != null) {
    String overridenRuleStr = session.getServletContext().getInitParameter(SYS_HDR_MOD_OVERRIDE);
    if (overridenRuleStr != null)
    {
      overridenRule = ModifiableRule.valueOf(overridenRuleStr);
    }
  }
  return overridenRule;            
}

origin: org.restcomm/restcomm-connect.telephony.api

public static SipSession getLinkedSession(SipServletMessage message) {
  SipSession sipSession = null;
  if (message.getSession().isValid()) {
    sipSession = (SipSession) message.getSession().getAttribute(B2BUA_LINKED_SESSION);
  }
  if (sipSession == null) {
    if(logger.isInfoEnabled()) {
      logger.info("SIP SESSION is NULL");
    }
  }
  return sipSession;
}
origin: org.restcomm/restcomm-connect.telephony.api

  logger.info(String.format("B2BUA: Got response: \n %s", response));
if (response.getSession() == null || !response.getSession().isValid()) {
  if (logger.isDebugEnabled()) {
    logger.debug("Response session is either null or invalidated");
if (getLinkedSession(response) == null || !getLinkedSession(response).isValid()) {
  if (logger.isDebugEnabled()) {
    logger.debug("Linked session of response is either null or invalidated");
  response.getSession().setAttribute(B2BUA_LAST_FINAL_RESPONSE, response);
  SipServletRequest request = (SipServletRequest) getLinkedSession(response).getAttribute(B2BUA_LAST_REQUEST);
  CallDetailRecord callRecord = records.getCallDetailRecord((Sid) request.getSession().getAttribute(CDR_SID));
    (!response.getSession().getState().equals(SipSession.State.TERMINATED))) {
  response.getSession().setAttribute(B2BUA_LAST_RESPONSE, response);
SipServletRequest linkedRequest = (SipServletRequest) getLinkedSession(response).getAttribute(B2BUA_LAST_REQUEST);
SipServletResponse clonedResponse = linkedRequest.createResponse(response.getStatus());
SipURI originalURI = null;
CallDetailRecord callRecord = records.getCallDetailRecord((Sid) linkedRequest.getSession().getAttribute(CDR_SID));
Sid organizationSid = daoManager.getAccountsDao().getAccount(callRecord.getAccountSid()).getOrganizationSid();
origin: org.restcomm/restcomm-connect.telephony.api

public static SipServletRequest getLinkedRequest(SipServletMessage message) {
  SipSession linkedB2BUASession = getLinkedSession(message);
  if (linkedB2BUASession != null) {
    SipServletRequest linkedRequest = (SipServletRequest) linkedB2BUASession.getAttribute(B2BUA_LAST_REQUEST);
    return linkedRequest;
  }
  return null;
}
origin: org.mobicents.servlet.sip.examples/shopping-demo-business-jsr309

stringBuffer.append(". Press 1 to confirm and 2 to decline.");				
sipServletRequest.getSession().setAttribute("speechUri",
    java.net.URI.create("data:" + URLEncoder.encode("ts("+ stringBuffer +")", "UTF-8")));
sipServletRequest.getSession().setAttribute("customerName", customerName);
sipServletRequest.getSession().setAttribute("customerPhone", customerPhone);
sipServletRequest.getSession().setAttribute("amountOrder", amount);
sipServletRequest.getSession().setAttribute("orderId", orderId);
sipServletRequest.getSession().setAttribute("connection", conn);
sipServletRequest.getSession().setAttribute("mediaGroup", mg);
sipServletRequest.getSession().setAttribute("mediaSession", mediaSession);
sipServletRequest.getSession().setAttribute("orderApproval", true);
sipServletRequest.getSession().setAttribute("caller", (String)Contexts.getApplicationContext().get("caller.sip"));
sipServletRequest.getSession().setAttribute("callerDomain", (String)Contexts.getApplicationContext().get("caller.domain"));
sipServletRequest.getSession().setAttribute("callerPassword", (String)Contexts.getApplicationContext().get("caller.password"));
sipServletRequest.send();
mg.getSignalDetector().addListener(new DTMFListener(mg, sipServletRequest.getSession(), MMSUtil.audioFilePath));
origin: org.mobicents.servlet.sip/restcomm.media

private void terminate() {
  final SipSession sipSession = initialInvite.getSession();
  final SipServletRequest bye = sipSession.createRequest("BYE");
  try {
    bye.send();
  } catch(final IOException exception) {
    logger.error(exception);
  }
  server.destroyMediaSession(session);
}
origin: org.mobicents.servlet.sip/restcomm.media

private void cleanup() {
  server.destroyMediaSession(session);
  initialInvite.getSession().invalidate();	  
}
origin: org.mobicents.servlet.sip/sip-servlets-impl

public void forward(ServletRequest request, ServletResponse response)
    throws ServletException, IOException {
  if(request != null) {
    ((SipServletRequest)request).getSession().setHandler(handler.getName());
  } else {
    ((SipServletResponse)response).getSession().setHandler(handler.getName());
  }
  Servlet servlet = handler.allocate();
  servlet.service(request, response);
  handler.deallocate(servlet);
}
origin: org.mobicents.servlet.sip/sip-servlets-impl

State.TERMINATED.equals(((MobicentsSipSession)session1).getState()) ||
State.TERMINATED.equals(((MobicentsSipSession)session2).getState()) ||
!session1.getApplicationSession().equals(session2.getApplicationSession()) ||
(sessionMap.get(((MobicentsSipSession)session1).getKey()) != null && sessionMap.get(((MobicentsSipSession)session1).getKey()) != ((MobicentsSipSession)session2).getKey())  ||
(sessionMap.get(((MobicentsSipSession)session2).getKey()) != null && sessionMap.get(((MobicentsSipSession)session2).getKey()) != ((MobicentsSipSession)session1).getKey())) {
origin: org.restcomm/restcomm-connect.telephony.api

public static SipServletResponse getLinkedResponse(SipServletMessage message) {
  SipSession linkedB2BUASession = getLinkedSession(message);
  // if this is an ACK that belongs to a B2BUA session, then we proxy it to the other client
  if (linkedB2BUASession != null) {
    SipServletResponse response = (SipServletResponse) linkedB2BUASession.getAttribute(B2BUA_LAST_RESPONSE);
    return response;
  }
  return null;
}
origin: org.mobicents.servlet.sip.examples/shopping-demo-business-jsr309

stringBuffer.append(" minute. Thank you. Bye.");				
sipServletRequest.getSession().setAttribute("speechUri",
    java.net.URI.create("data:" + URLEncoder.encode("ts("+ stringBuffer +")", "UTF-8")));
Thread.sleep(300);
sipServletRequest.setContent(sdpOffer, "application/sdp");	
MediaGroup mg = mediaSession.createMediaGroup(MediaGroup.PLAYER_SIGNALDETECTOR);
sipServletRequest.getSession().setAttribute("mediaGroup", mg);
sipServletRequest.getSession().setAttribute("mediaSession", mediaSession);
sipServletRequest.getSession().setAttribute("customerName", customerfullname);
sipServletRequest.getSession().setAttribute("customerPhone", cutomerphone);
sipServletRequest.getSession().setAttribute("amountOrder", amount);
sipServletRequest.getSession().setAttribute("orderId", orderId);
sipServletRequest.getSession().setAttribute("connection", conn);
sipServletRequest.getSession().setAttribute("shipping", true);
sipServletRequest.send();
mg.getSignalDetector().addListener(new DTMFListener(mg, sipServletRequest.getSession(), MMSUtil.audioFilePath));
origin: org.mobicents.servlet.sip/sip-servlets-impl

final MobicentsSipSession sessionImpl = (MobicentsSipSession) session;
final SipServletRequestImpl newSubsequentServletRequest = (SipServletRequestImpl) session.createRequest(origRequest.getMethod());
origin: org.mobicents.servlet.sip.examples/shopping-demo-business-jsr309

public static void playAnnouncement(MediaGroup mg, SipSession sipSession, String pathToAudioDirectory) {
  try {
    java.net.URI uri = (java.net.URI) sipSession.getAttribute("speechUri");
    if(sipSession.getAttribute("orderApproval") != null) {
  
      logger.info("Playing confirmation announcement : " + uri);
      mg.getPlayer().play(uri, null, null);
      mg.getSignalDetector().receiveSignals(1, null, null, null);
      sipSession.setAttribute("DTMFSession", DTMFListener.DTMF_SESSION_STARTED);
      logger.info("Waiting for DTMF at the same time..");				
    } else if (sipSession.getAttribute("deliveryDate") != null) {			
      logger.info("Playing Delivery Date Announcement : " + uri);
      mg.getPlayer().play(uri, null, null);
      mg.getSignalDetector().receiveSignals(1, null, null, null);
      sipSession.setAttribute("DTMFSession", DTMFListener.DTMF_SESSION_STARTED);
      logger.info("Waiting for DTMF at the same time..");
    } else if (sipSession.getAttribute("shipping") != null) {			
      logger.info("Playing shipping announcement : " + uri);
      mg.getPlayer().play(uri, null, null);
      mg.getPlayer().addListener(new EndCallWhenPlaybackCompletedListener(sipSession));
      logger.info("shipping announcement played. tearing down the call");
    }        
  } catch (Exception e) {
    logger.error(e);
  }
}
origin: org.mobicents.servlet.sip.examples/shopping-demo-business-jsr309

  public void onEvent(SdpPortManagerEvent arg0) {
    if((Boolean.TRUE).equals(inviteRequest.getSession().getAttribute("playAnnouncement"))) {
      NetworkConnection connection = (NetworkConnection) inviteRequest.getSession().getAttribute("connection");
      MediaGroup mg =(MediaGroup)inviteRequest.getSession().getAttribute("mediaGroup");
      try {
        playAnnouncement(mg, inviteRequest.getSession(), (String)inviteRequest.getSession().getAttribute("audioFilePath"));
      }catch (Exception e) {
        logger.error(e);
      }

    }

  }
}
origin: org.mobicents.servlet.sip.examples/shopping-demo-business-jsr309

sipServletRequest.setContent(sdpOffer, "application/sdp");	
MediaGroup mg = mediaSession.createMediaGroup(MediaGroup.PLAYER_SIGNALDETECTOR);
sipServletRequest.getSession().setAttribute("mediaGroup", mg);
sipServletRequest.getSession().setAttribute("mediaSession", mediaSession);
sipServletRequest.getSession().setAttribute("customerName", customerfullname);
sipServletRequest.getSession().setAttribute("customerPhone", cutomerphone);
sipServletRequest.getSession().setAttribute("amountOrder", amount);
sipServletRequest.getSession().setAttribute("orderId", orderId);
sipServletRequest.getSession().setAttribute("connection", conn);			
sipServletRequest.getSession().setAttribute("deliveryDate", true);
String announcementFile = MMSUtil.audioFilePath + "/OrderDeliveryDate.wav";
sipServletRequest.getSession().setAttribute("speechUri", java.net.URI.create(announcementFile));
sipServletRequest.getSession().setAttribute("caller", (String)Contexts.getApplicationContext().get("caller.sip"));
sipServletRequest.getSession().setAttribute("callerDomain", (String)Contexts.getApplicationContext().get("caller.domain"));
sipServletRequest.getSession().setAttribute("callerPassword", (String)Contexts.getApplicationContext().get("caller.password"));
sipServletRequest.send();
mg.getSignalDetector().addListener(new DTMFListener(mg, sipServletRequest.getSession(), MMSUtil.audioFilePath));
origin: org.mobicents.servlet.sip/sip-servlets-impl

    newRequest, origRequest.getSession().getServletContext());	
final FromHeader newFromHeader = (FromHeader) newRequest.getHeader(FromHeader.NAME);
newFromHeader.removeParameter("tag");
origin: org.mobicents.servlet.sip.examples/shopping-demo-business-jsr309

String dateAndTime = (String) session.getAttribute("dateAndTime");
if(dateAndTime == null) {
  dateAndTime = "";
    InitialContext ctx = new InitialContext();
    OrderManager orderManager = (OrderManager) ctx.lookup("shopping-demo/OrderManagerBean/remote");
    orderManager.setDeliveryDate(session.getAttribute("orderId"), timeStamp);
  } catch (NamingException e) {
    logger.error("An exception occured while retrieving the EJB OrderManager",e);
  try {
    URI delieryDateSummary = java.net.URI.create("data:" + URLEncoder.encode("ts("+ stringBuffer +")", "UTF-8"));
    session.setAttribute("speechUri",
        delieryDateSummary);
    java.io.File speech = new File("deliveryDate.wav");
    logger.info("Playing delivery date summary : " + "TTS:" + stringBuffer);
    MediaGroup mg = (MediaGroup) session.getAttribute("mediaGroup");
    mg.getPlayer().play(delieryDateSummary, null, null);
    mg.getPlayer().addListener(new EndCallWhenPlaybackCompletedListener(session));
  session.setAttribute("dateAndTime", dateAndTime);
  return false;
origin: org.restcomm/restcomm-connect.telephony.api

  private static void sendCallInfoStreamEvent(ActorSystem system, SipServletMessage message, CallStateChanged.State state) {
    SipSession session = message.getSession();
    Object sid = session.getAttribute(CDR_SID);
    if (sid != null) {
      CallInfo callInfo = new CallInfo(
          (Sid) sid,
          (Sid) session.getAttribute(CDR_ACCOUNT_SID),
          state,
          null,
          (String) session.getAttribute(CDR_DIRECTION),
          null,
          null,
          null,
          (String) session.getAttribute(CDR_FROM),
          (String) session.getAttribute(CDR_TO),
          null, null, false, false, false, null, null
      );
      system.eventStream().publish(new CallInfoStreamEvent(callInfo));
    }
  }
}
javax.servlet.sipSipSession

Javadoc

Represents point-to-point SIP relationships. It roughly corresponds to a SIP dialog. In particular, for UAs it maintains (or is otherwise associated with) dialog state so as to be able to create subequent requests belonging to that dialog (using createRequest). For UACs, SipSession extend the notion of SIP dialogs to have well-defined state before a dialog has been established and after a final non-2xx terminates an early dialog. This allows UACs to create "subsequent" requests without having an established dialog. The effect is that the subsequent request will have the same Call-ID, From and To headers (with the same From tag and without a To tag), the will exist in the same CSeq space. All messages are potentially associated with a SipSession. The SipSession can be retrieved from the message by calling SipServletMessage.getSession().

Most used methods

  • createRequest
    Returns a new request object. This method is used by user agents only. Note that this method must no
  • getAttribute
    Returns the object bound with the specified name in this session, or null if no object is bound unde
  • setAttribute
    Binds an object to this session, using the name specified. If an object of the same name is already
  • getApplicationSession
    Returns the application session with which this SipSession is associated.
  • getServletContext
    Returns the ServletContext to which this session belongs. By definition, there is one ServletContext
  • getState
    Returns the current SIP dialog state, which is one of INITIAL, EARLY, CONFIRMED, or TERMINATED. Thes
  • invalidate
    Invalidates this session and unbinds any objects bound to it. A session cannot be invalidate if it i
  • isValid
    Returns true if this SipSession is valid, false otherwise. The SipSession can be invalidated by call
  • setHandler
    Sets the handler for this SipSession. This method can be used to explicitly specify the name of the

Popular in Java

  • Reactive rest calls using spring rest template
  • getResourceAsStream (ClassLoader)
  • setRequestProperty (URLConnection)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • Font (java.awt)
    The Font class represents fonts, which are used to render text in a visible way. A font provides the
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • List (java.util)
    An ordered collection (also known as a sequence). The user of this interface has precise control ove
  • UUID (java.util)
    UUID is an immutable representation of a 128-bit universally unique identifier (UUID). There are mul
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • JButton (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now