public void onEvent(PlayerEvent event) { Player player = event.getSource(); MediaGroup mg = player.getContainer(); if (!isBye) { if (event.isSuccessful() && (PlayerEvent.PLAY_COMPLETED == event.getEventType())) { MediaSession mediaSession = event.getSource().getMediaSession(); SipSession sipSession = (SipSession) mediaSession.getAttribute("SIP_SESSION"); sipSession.setAttribute("MEDIA_GROUP", mg); SipApplicationSession sipAppSession = sipSession.getApplicationSession(); try { Recorder recoredr = mg.getRecorder(); logger.info("recording the user at " + RECORDER); URI prompt = URI.create(RECORDER); recoredr.record(prompt, null, null); TimerService timer = (TimerService) getServletContext().getAttribute(TIMER_SERVICE); timer.createTimer(sipAppSession, RECORDING_DELAY, false, sipSession.getId()); } catch (MsControlException e) { logger.error("An unexpected error happened ", e); } } else { logger.error("Player didn't complete successfully "); } } }
@Override protected void doInvite(SipServletRequest request) throws ServletException, IOException { if (logger.isInfoEnabled()) { logger.info("Simple Servlet: Got request:\n" + request.getMethod()); } SipServletResponse sipServletResponse = request.createResponse(SipServletResponse.SC_RINGING); sipServletResponse.send(); sipServletResponse = request.createResponse(SipServletResponse.SC_OK); sipServletResponse.send(); if (CALLEE_SEND_BYE.equalsIgnoreCase(((SipURI) request.getTo().getURI()).getUser())) { TimerService timer = (TimerService) getServletContext().getAttribute(TIMER_SERVICE); timer.createTimer( request.getApplicationSession(), byeDelay, false, request.getSession().getId()); } }
protected void doInvite(SipServletRequest req) throws ServletException, IOException { serverEntryLog(); logger.debug("---doInvite---"); SipServletResponse resp = req.createResponse(180); resp.send(); // just set timer - we expect a CANCEL to arrive... SipSession sipSession = req.getSession(); sipSession.setAttribute("invite", req); timerService.createTimer( req.getApplicationSession(), 5000, true, UasCancelServlet.class.getName()); }