| | |
| | | import javax.sip.address.AddressFactory; |
| | | import javax.sip.address.SipURI; |
| | | import javax.sip.header.ContentTypeHeader; |
| | | import javax.sip.header.ExpiresHeader; |
| | | import javax.sip.header.HeaderFactory; |
| | | import javax.sip.header.ViaHeader; |
| | | import javax.sip.message.MessageFactory; |
| | |
| | | public void responseAck(RequestEvent evt, int statusCode) throws SipException, InvalidArgumentException, ParseException { |
| | | Response response = getMessageFactory().createResponse(statusCode, evt.getRequest()); |
| | | ServerTransaction serverTransaction = getServerTransaction(evt); |
| | | if (serverTransaction == null) { |
| | | logger.warn("回复失败:{}", response); |
| | | return; |
| | | } |
| | | serverTransaction.sendResponse(response); |
| | | if (statusCode >= 200) { |
| | | if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) { |
| | | |
| | | if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); |
| | | } |
| | | } |
| | |
| | | response.setReasonPhrase(msg); |
| | | ServerTransaction serverTransaction = getServerTransaction(evt); |
| | | serverTransaction.sendResponse(response); |
| | | if (statusCode >= 200) { |
| | | if (statusCode >= 200 && !"NOTIFY".equals(evt.getRequest().getMethod())) { |
| | | if (serverTransaction.getDialog() != null) serverTransaction.getDialog().delete(); |
| | | } |
| | | } |
| | |
| | | * @throws InvalidArgumentException |
| | | * @throws ParseException |
| | | */ |
| | | public void responseAck(RequestEvent evt, String sdp) throws SipException, InvalidArgumentException, ParseException { |
| | | public void responseSdpAck(RequestEvent evt, String sdp) throws SipException, InvalidArgumentException, ParseException { |
| | | Response response = getMessageFactory().createResponse(Response.OK, evt.getRequest()); |
| | | SipFactory sipFactory = SipFactory.getInstance(); |
| | | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "SDP"); |
| | |
| | | getServerTransaction(evt).sendResponse(response); |
| | | } |
| | | |
| | | /** |
| | | * 回复带xml的200 |
| | | * @param evt |
| | | * @param xml |
| | | * @throws SipException |
| | | * @throws InvalidArgumentException |
| | | * @throws ParseException |
| | | */ |
| | | public Response responseXmlAck(RequestEvent evt, String xml) throws SipException, InvalidArgumentException, ParseException { |
| | | Response response = getMessageFactory().createResponse(Response.OK, evt.getRequest()); |
| | | SipFactory sipFactory = SipFactory.getInstance(); |
| | | ContentTypeHeader contentTypeHeader = sipFactory.createHeaderFactory().createContentTypeHeader("APPLICATION", "MANSCDP+xml"); |
| | | response.setContent(xml, contentTypeHeader); |
| | | |
| | | SipURI sipURI = (SipURI)evt.getRequest().getRequestURI(); |
| | | |
| | | Address concatAddress = sipFactory.createAddressFactory().createAddress( |
| | | sipFactory.createAddressFactory().createSipURI(sipURI.getUser(), sipURI.getHost()+":"+sipURI.getPort() |
| | | )); |
| | | response.addHeader(sipFactory.createHeaderFactory().createContactHeader(concatAddress)); |
| | | response.addHeader(evt.getRequest().getHeader(ExpiresHeader.NAME)); |
| | | getServerTransaction(evt).sendResponse(response); |
| | | return response; |
| | | } |
| | | |
| | | public Element getRootElement(RequestEvent evt) throws DocumentException { |
| | | return getRootElement(evt, "gb2312"); |
| | | } |