public void unregister() throws SipUriSyntaxException { if (getInitialRequestManager().getRegisterHandler().isRegistered()) { String requestUri = RFC3261.SIP_SCHEME + RFC3261.SCHEME_SEPARATOR + userAgent.getDomain(); MessageInterceptor messageInterceptor = new MessageInterceptor() { @Override public void postProcess(SipMessage sipMessage) { initialRequestManager.registerHandler.unregister(); SipHeaders sipHeaders = sipMessage.getSipHeaders(); SipHeaderFieldValue contact = sipHeaders.get(new SipHeaderFieldName(RFC3261.HDR_CONTACT)); contact.addParam(new SipHeaderParamName(RFC3261.PARAM_EXPIRES), "0"); } }; initialRequestManager.createInitialRequest( requestUri, RFC3261.METHOD_REGISTER, profileUri, registerCallID, null, messageInterceptor); // initialRequestManager.registerHandler.unregister(); } }
/** * For the moment we consider that only one profile uri is used at a time. * * @throws SipUriSyntaxException */ public SipRequest register() throws SipUriSyntaxException { String domain = userAgent.getDomain(); String requestUri = RFC3261.SIP_SCHEME + RFC3261.SCHEME_SEPARATOR + domain; SipListener sipListener = userAgent.getSipListener(); profileUri = RFC3261.SIP_SCHEME + RFC3261.SCHEME_SEPARATOR + userAgent.getUserpart() + RFC3261.AT + domain; registerCallID = Utils.generateCallID(userAgent.getConfig().getLocalInetAddress()); SipRequest sipRequest = initialRequestManager.createInitialRequest( requestUri, RFC3261.METHOD_REGISTER, profileUri, registerCallID); if (sipListener != null) { sipListener.registering(sipRequest); } return sipRequest; }
public void terminate(SipRequest sipRequest) { String callId = Utils.getMessageCallId(sipRequest); if (!guiClosedCallIds.contains(callId)) { guiClosedCallIds.add(callId); } Dialog dialog = dialogManager.getDialog(callId); SipRequest inviteWithAuth = getInviteWithAuth(callId); if (dialog != null) { SipRequest originatingRequest; if (inviteWithAuth != null) { originatingRequest = inviteWithAuth; } else { originatingRequest = sipRequest; } ClientTransaction clientTransaction = transactionManager.getClientTransaction(originatingRequest); if (clientTransaction != null) { synchronized (clientTransaction) { DialogState dialogState = dialog.getState(); if (dialog.EARLY.equals(dialogState)) { initialRequestManager.createCancel(inviteWithAuth, midDialogRequestManager, profileUri); } else if (dialog.CONFIRMED.equals(dialogState)) { // clientTransaction not yet removed midDialogRequestManager.generateMidDialogRequest(dialog, RFC3261.METHOD_BYE, null); guiClosedCallIds.remove(callId); } } } else { // clientTransaction Terminated and removed logger.debug("clientTransaction null"); midDialogRequestManager.generateMidDialogRequest(dialog, RFC3261.METHOD_BYE, null); guiClosedCallIds.remove(callId); } } else { InviteClientTransaction inviteClientTransaction = (InviteClientTransaction) transactionManager.getClientTransaction(inviteWithAuth); if (inviteClientTransaction == null) { logger.error("cannot find invite client transaction" + " for call " + callId); } else { SipResponse sipResponse = inviteClientTransaction.getLastResponse(); if (sipResponse != null) { int statusCode = sipResponse.getStatusCode(); if (statusCode < RFC3261.CODE_200_OK) { initialRequestManager.createCancel(inviteWithAuth, midDialogRequestManager, profileUri); } } } } switch (userAgent.getMediaMode()) { case captureAndPlayback: userAgent.getMediaManager().stopSession(); SoundManager soundManager = userAgent.getSoundManager(); if (soundManager != null) { soundManager.closeLines(); } break; case echo: Echo echo = userAgent.getEcho(); if (echo != null) { echo.stop(); userAgent.setEcho(null); } break; case file: MediaManager mediaManager = userAgent.getMediaManager(); mediaManager.stopSession(); break; default: break; } }
public SipRequest invite(String requestUri, String callId) throws SipUriSyntaxException { return initialRequestManager.createInitialRequest( requestUri, RFC3261.METHOD_INVITE, profileUri, callId); }