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 "); } } }
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); } }