javax.sip.message.Request类的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(15.1k)|赞(0)|评价(0)|浏览(361)

本文整理了Java中javax.sip.message.Request类的一些代码示例,展示了Request类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request类的具体详情如下:
包路径:javax.sip.message.Request
类名称:Request

Request介绍

暂无

代码示例

代码示例来源:origin: org.mobicents.examples/converged-demo-callcontrol-sbb

  1. public void execute(RequestEvent event) {
  2. Request request = event.getRequest();
  3. final String calleeCallId = ((CallIdHeader) request
  4. .getHeader(CallIdHeader.NAME)).getCallId();
  5. String method = request.getMethod();
  6. if (Request.BYE.equals(method)) {
  7. handleBye(calleeCallId, request);
  8. }
  9. }
  10. }

代码示例来源:origin: org.mobicents.examples/sip11-loadtest-with-dialogs-sbb

  1. public void onTimerEvent(TimerEvent event, ActivityContextInterface aci) {
  2. try {
  3. DialogActivity dialog = (DialogActivity)aci.getActivity();
  4. Request request = dialog.createRequest(Request.BYE);
  5. request.addHeader(getContactHeader());
  6. ClientTransaction clientTransaction = sipFactoryProvider.getNewClientTransaction(request);
  7. clientTransaction.sendRequest();
  8. } catch (Exception ex) {
  9. ex.printStackTrace();
  10. }
  11. }

代码示例来源:origin: org.apache.camel/camel-sip

  1. private void processPublish(RequestEvent requestEvent,
  2. ServerTransaction serverTransactionId) {
  3. try {
  4. Request request = requestEvent.getRequest();
  5. LOG.debug("SipPresenceAgentListener: Received a Publish request, sending OK");
  6. LOG.debug("SipPresenceAgentListener request: {}", request);
  7. EventHeader eventHeader = (EventHeader) requestEvent.getRequest().getHeader(EventHeader.NAME);
  8. Response response = sipPresenceAgent.getConfiguration().getMessageFactory().createResponse(202, request);
  9. sipPresenceAgent.getProvider().sendResponse(response);
  10. // Send notification to subscriber
  11. sendNotification(eventHeader, false, request.getContent());
  12. } catch (Exception e) {
  13. LOG.error("Exception thrown during publish/notify processing in the Sip Presence Agent Listener", e);
  14. }
  15. }

代码示例来源:origin: org.apache.camel/camel-sip

  1. public void processRequest(RequestEvent requestReceivedEvent) {
  2. Request request = requestReceivedEvent.getRequest();
  3. ServerTransaction serverTransactionId = requestReceivedEvent
  4. .getServerTransaction();
  5. String viaBranch = ((ViaHeader)(request.getHeaders(ViaHeader.NAME).next())).getParameter("branch");
  6. LOG.debug("Request: {}", request.getMethod());
  7. LOG.debug("Server Transaction Id: {}", serverTransactionId);
  8. LOG.debug("Received From Branch: {}", viaBranch);
  9. if (request.getMethod().equals(Request.NOTIFY)) {
  10. processNotify(requestReceivedEvent, serverTransactionId);
  11. }
  12. }

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

  1. public static String findRouteOrRequestUriTransport(Request request) {
  2. RouteHeader route = (RouteHeader) request.getHeader(RouteHeader.NAME);
  3. if(route != null) {
  4. URI uri = route.getAddress().getURI();
  5. return findURITransport(uri, request.getContentLength().getContentLength());
  6. }
  7. URI ruri = request.getRequestURI();
  8. return findURITransport(ruri, request.getContentLength().getContentLength());
  9. }
  10. // https://github.com/Mobicents/sip-servlets/issues/62

代码示例来源:origin: org.jitsi/jain-sip-ri-ossonly

  1. /**
  2. * Removes all via headers from <tt>request</tt> and replaces them with a new one, equal to
  3. * the one that was top most.
  4. *
  5. * @param request the Request whose branchID we'd like to remove.
  6. *
  7. */
  8. private void removeBranchID(Request request) {
  9. ViaHeader viaHeader = (ViaHeader) request.getHeader(ViaHeader.NAME);
  10. viaHeader.removeParameter("branch");
  11. }

代码示例来源:origin: org.jitsi/jain-sip-ri-ossonly

  1. while (headerNames.hasNext()) {
  2. String headerName = headerNames.next();
  3. if ( reoriginatedRequest.getHeader(headerName) == null) {
  4. ListIterator<SIPHeader> iterator = challengedRequest.getHeaders(headerName);
  5. while (iterator.hasNext()) { reoriginatedRequest.addHeader(iterator.next()); }
  6. reoriginatedRequest.removeHeader(AuthorizationHeader.NAME);
  7. reoriginatedRequest.removeHeader(ProxyAuthorizationHeader.NAME);
  8. CSeqHeader cSeq = (CSeqHeader) reoriginatedRequest.getHeader((CSeqHeader.NAME));
  9. try {
  10. cSeq.setSeqNumber(cSeq.getSeqNumber() + 1l);
  11. SipURI sipUri = (SipURI) reoriginatedRequest.getRequestURI();
  12. sipUri.setMAddrParam(hop.getHost());
  13. if ( hop.getPort() != -1 ) sipUri.setPort(hop.getPort());
  14. SipURI requestUri = (SipURI) challengedTransaction.getRequest().getRequestURI();
  15. while (authHeaders.hasNext()) {
  16. authHeader = (WWWAuthenticateHeader) authHeaders.next();
  17. URI uri = reoriginatedRequest.getRequestURI();
  18. sipDomain = credHash.getSipDomain();
  19. authorization = this.getAuthorization(reoriginatedRequest
  20. .getMethod(), uri.toString(),
  21. (reoriginatedRequest.getContent() == null) ? "" : new String(
  22. reoriginatedRequest.getRawContent()), authHeader, credHash);
  23. } else {
  24. UserCredentials userCreds = ((AccountManager) this.accountManager).getCredentials(challengedTransaction, realm);

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

  1. newRequest.removeHeader(ViaHeader.NAME);
  2. ViaHeader viaHeader = JainSipUtils.createViaHeader(
  3. getSipNetworkInterfaceManager(), newRequest, branch, null);
  4. newRequest.addHeader(viaHeader);
  5. final FromHeader newFromHeader = (FromHeader) newRequest.getHeader(FromHeader.NAME);
  6. ((ToHeader) newRequest.getHeader(ToHeader.NAME))
  7. .removeParameter("tag");
  8. newRequest.removeHeader(RecordRouteHeader.NAME);
  9. if(!Request.REGISTER.equalsIgnoreCase(newRequest.getMethod())) {
  10. try {
  11. if(!Request.REGISTER.equalsIgnoreCase(newRequest.getMethod())) {
  12. if(JainSipUtils.CONTACT_HEADER_METHODS.contains(newRequest.getMethod())) {
  13. String fromName = null;
  14. String displayName = ((MessageExt)newRequest).getFromHeader().getAddress().getDisplayName();
  15. if(newRequest.getHeader(ContactHeader.NAME) != null &&
  16. ((ContactHeader)newRequest.getHeader(ContactHeader.NAME)).getAddress().getURI() instanceof javax.sip.address.SipURI) {
  17. fromName = ((javax.sip.address.SipURI)((MessageExt)newRequest).getFromHeader().getAddress().getURI()).getUser();
  18. newRequest.removeHeader(ContactHeader.NAME);
  19. if(contactHeader != null) {
  20. newRequest.addHeader(contactHeader);

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

  1. public static void optimizeRouteHeaderAddressForInternalRoutingrequest(SipConnector sipConnector, Request request, MobicentsSipSession session, SipFactoryImpl sipFactoryImpl, String transport) {
  2. RouteHeader rh = (RouteHeader) request.getHeader(RouteHeader.NAME);
  3. javax.sip.address.URI uri = null;
  4. if(rh != null) {
  5. uri = rh.getAddress().getURI();
  6. } else {
  7. uri = request.getRequestURI();
  8. }
  9. if(uri.isSipURI()) {
  10. javax.sip.address.SipURI sipUri = (javax.sip.address.SipURI) uri;
  11. optimizeUriForInternalRoutingRequest(sipConnector, sipUri, session, sipFactoryImpl, transport);
  12. }
  13. }

代码示例来源:origin: org.mobicents.examples/sip-wake-up-sbb

  1. final String body = new String(request.getRawContent());
  2. final int firstTokenStart = body.indexOf(FIRST_TOKEN);
  3. final int timerDurationStart = firstTokenStart + FIRST_TOKEN_LENGTH;
  4. setCallId((CallIdHeader) request.getHeader(CallIdHeader.NAME));
  5. .getHeader(FromHeader.NAME);
  6. if (tracer.isInfoEnabled()) {
  7. tracer.info("Received a valid message from "

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

  1. final String method = clonedRequest.getMethod();
  2. final ProxyImpl proxy = (ProxyImpl) proxyBranch.getProxy();
  3. final SipFactoryImpl sipFactoryImpl = proxy.getSipFactoryImpl();
  4. RouteHeader rHeader = (RouteHeader) clonedRequest.getHeader(RouteHeader.NAME);
  5. if(rHeader != null) {
  6. String nextApp = ((javax.sip.address.SipURI)rHeader.getAddress().getURI()).getParameter(MessageDispatcher.RR_PARAM_APPLICATION_NAME);
  7. clonedRequest.removeFirst(RouteHeader.NAME);
  8. rHeader = (RouteHeader) clonedRequest.getHeader(RouteHeader.NAME);
  9. if(clonedRequest.getRequestURI().isSipURI()) {
  10. outboundTransport = ((javax.sip.address.SipURI)clonedRequest.getRequestURI()).getTransportParam();
  11. if(destination != null && destination.isSipURI()) {
  12. String destinationTransport = ((SipURI)destination).getTransportParam();
  13. Via via = ((Via)clonedRequest.getHeader(Via.NAME));
  14. String inboundTransport = via.getTransport();
  15. if(inboundTransport == null) inboundTransport = ListeningPoint.UDP;
  16. Header route = clonedRequest.getHeader("Route");
  17. if(route == null ||
  18. clonedRequest.setRequestURI(((URIImpl)destination).getURI());
  19. clonedRequest.removeHeader(ViaHeader.NAME);
  20. clonedRequest.removeHeader(RecordRouteHeader.NAME);

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

  1. if(methodRequest.getHeader(ContactHeader.NAME) != null) {
  2. FromHeader from = (FromHeader) methodRequest.getHeader(FromHeader.NAME);
  3. String displayName = from.getAddress().getDisplayName();
  4. String userName = null;
  5. methodRequest.setHeader(contactHeader);
  6. } catch (Exception e) {
  7. logger.error("Can not create contact header for subsequent request " + method + " for session " + key, e);
  8. ListIterator<ViaHeader> viaHeaders = methodRequest.getHeaders(ViaHeader.NAME);
  9. if(viaHeaders != null && viaHeaders.hasNext()) {
  10. ViaHeader viaHeader = viaHeaders.next();
  11. methodRequest.removeHeader(ViaHeader.NAME);
  12. ViaHeader viaHeader = JainSipUtils.createViaHeader(
  13. sipFactory.getSipNetworkInterfaceManager(), methodRequest, branch, outboundInterface);
  14. methodRequest.addHeader(viaHeader);
  15. javax.sip.address.URI requestUri = (javax.sip.address.URI) request.getRequestURI().clone();
  16. try {
  17. request.setMethod(method);
  18. } catch (ParseException e) {
  19. throw new IllegalArgumentException("Unexpected exception happened on setting method " + method, e);
  20. request.setRequestURI(requestUri);
  21. ((MessageExt)request).setApplicationData(null);

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

  1. clonedRequest.addHeader(viaHeader);
  2. } else {
  3. if(SipRouteModifier.NO_ROUTE.equals(sipRouteModifier)) {
  4. clonedRequest.addHeader(viaHeader);
  5. clonedRequest.addHeader(viaHeader);
  6. .getHeader(MaxForwardsHeader.NAME);
  7. if (maxForwardsHeader == null) {
  8. maxForwardsHeader = SipFactoryImpl.headerFactory.createMaxForwardsHeader(JainSipUtils.MAX_FORWARD_HEADER_VALUE);
  9. clonedRequest.addHeader(maxForwardsHeader);
  10. } else {
  11. if(maxForwardsHeader.getMaxForwards() - 1 > 0) {
  12. } else if ( clonedRequest.getMethod().equals("ACK") ) {
  13. if(logger.isInfoEnabled()) {
  14. logger.info("Sending the ACK through the dialog " + clonedRequest);
  15. } else {
  16. Request dialogRequest=
  17. dialog.createRequest(clonedRequest.getMethod());
  18. Object content=clonedRequest.getContent();
  19. if (content!=null) {
  20. ContentTypeHeader contentTypeHeader= (ContentTypeHeader)
  21. clonedRequest.getHeader(ContentTypeHeader.NAME);
  22. if (contentTypeHeader!=null) {
  23. dialogRequest.setContent(content,contentTypeHeader);

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

  1. URI requestURI = request.getRequestURI();
  2. JoinHeader joinHeader = (JoinHeader)request.getHeader(JoinHeader.NAME);
  3. ReplacesHeader replacesHeader = (ReplacesHeader)request.getHeader(ReplacesHeader.NAME);
  4. if(joinHeader != null || replacesHeader != null) {
  5. if(logger.isDebugEnabled()) {
  6. if(!Request.INVITE.equals(request.getMethod())) {
  7. throw new DispatcherException(Response.BAD_REQUEST, "A Join or Replaces Header cannot be present in a request other than INVITE as per RFC 3911, Section 4 or RFC 3891, Section 3. Check your request " + request);

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

  1. final String requestMethod = request.getMethod();
  2. .getHeader(RouteHeader.NAME);
  3. String method = requestEvent.getRequest().getMethod();
  4. boolean goodMethod = method.equals(Request.ACK) || method.equals(Request.PRACK) || method.equals(Request.BYE) || method.equals(Request.CANCEL) || method.equals(Request.UPDATE) || method.equals(Request.INFO);
  5. if(logger.isDebugEnabled()) {
  6. try {
  7. if(request.getHeader(MaxForwardsHeader.NAME) == null){
  8. request.setHeader(SipFactoryImpl.headerFactory.createMaxForwardsHeader(70));
  9. request.removeFirst(RouteHeader.NAME);
  10. sipServletRequest.setPoppedRoute(routeHeader);
  11. final Parameters poppedAddress = (Parameters)routeHeader.getAddress().getURI();
  12. if(poppedAddress.getParameter(MessageDispatcher.RR_PARAM_PROXY_APP) != null ||
  13. (request.getRequestURI() instanceof javax.sip.address.SipURI && ((Parameters)request.getRequestURI()).getParameter(MessageDispatcher.RR_PARAM_PROXY_APP) != null)) {
  14. if(logger.isDebugEnabled()) {
  15. logger.debug("the request is for a proxy application, thus it is a subsequent request ");
  16. logger.error("Unexpected exception while processing request " + request,e);
  17. if(!Request.ACK.equalsIgnoreCase(request.getMethod())) {
  18. MessageDispatcher.sendErrorResponse(this, Response.SERVER_INTERNAL_ERROR, requestTransaction, request, sipProvider);

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

  1. final ContactHeader contactHeader = (ContactHeader) request.getHeader(ContactHeader.NAME);
  2. final ProxyImpl proxy = (ProxyImpl) proxyBranch.getProxy();
  3. if(proxyBranch.isAddToPath() && request.getMethod().equalsIgnoreCase(Request.REGISTER)) {
  4. ListIterator<ViaHeader> vias = request.getHeaders(ViaHeader.NAME);
  5. while (vias.hasNext() && nbVias <= 2) {
  6. vias.next();
  7. PathHeader pathHeader = (PathHeader) request.getHeader(PathHeader.NAME);
  8. javax.sip.address.SipURI pathURI = (javax.sip.address.SipURI) pathHeader.getAddress().getURI();
  9. String flowToken = generateFlowToken(originalRequest);
  10. RouteHeader routeHeader = sipFactoryImpl.getHeaderFactory().createRouteHeader(
  11. sipFactoryImpl.getAddressFactory().createAddress(routeURI));
  12. request.addHeader(routeHeader);
  13. } catch (ParseException e) {
  14. logger.error("Impossible to parse the following popped URI " + poppedURI, e);

代码示例来源:origin: org.apache.camel/camel-sip

  1. public void processRequest(RequestEvent requestEvent) {
  2. Request request = requestEvent.getRequest();
  3. ServerTransaction serverTransactionId = requestEvent.getServerTransaction();
  4. LOG.debug("Request: {}", request.getMethod());
  5. LOG.debug("Server Transaction Id: {}", serverTransactionId);
  6. if (request.getMethod().equals(Request.SUBSCRIBE)) {
  7. processSubscribe(requestEvent, serverTransactionId);
  8. } else if (request.getMethod().equals(Request.PUBLISH)) {
  9. processPublish(requestEvent, serverTransactionId);
  10. } else {
  11. LOG.debug("Received expected request with method: {}. No further processing done", request.getMethod());
  12. }
  13. }

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

  1. final MobicentsProxy proxy = session.getProxy();
  2. ContactHeader contactHeader = (ContactHeader)request.getHeader(ContactHeader.NAME);
  3. if(contactHeader != null && (((Parameters)contactHeader.getAddress().getURI()).getParameter("gruu") != null ||
  4. ((Parameters)contactHeader.getAddress().getURI()).getParameter("gr") != null)) {
  5. final FromHeader fromHeader = (FromHeader) request.getHeader(FromHeader.NAME);
  6. final javax.sip.address.URI fromUri = fromHeader.getAddress().getURI();
  7. String fromName = null;
  8. request.addHeader(contactHeader);
  9. final javax.sip.address.URI requestURI = request.getRequestURI();

代码示例来源:origin: org.mobicents.servlet.sip/sip-servlets-impl

  1. throw new IllegalStateException("the transaction state is such that it doesn't allow a PRACK to be sent now, or this response is provisional only, or a PRACK has already been generated");
  2. if(!Request.INVITE.equals(getTransaction().getRequest().getMethod())) {
  3. throw new Rel100Exception(Rel100Exception.NOT_INVITE);
  4. prackRequest.removeHeader(ViaHeader.NAME);
  5. ViaHeader viaHeader = JainSipUtils.createViaHeader(
  6. sipFactoryImpl.getSipNetworkInterfaceManager(), prackRequest, branch, session.getOutboundInterface());
  7. prackRequest.addHeader(viaHeader);
  8. ListIterator<RouteHeader> routeHeaders = prackRequest.getHeaders(RouteHeader.NAME);
  9. prackRequest.removeHeader(RouteHeader.NAME);
  10. while (routeHeaders.hasNext()) {
  11. RouteHeader routeHeader = routeHeaders.next();
  12. prackRequest.addHeader(routeHeader);

代码示例来源:origin: org.mobicents.servers.jainslee.enablers/sip-subscription-client-sbb

  1. Address contactAddress = addressFactory.createAddress(contactURI);
  2. ContactHeader contactHeader = headerFactory.createContactHeader(contactAddress);
  3. request.setHeader(contactHeader);
  4. request.addHeader(expiresHeader);
  5. request.addHeader(routeHeader);
  6. request.setContent(subscriptionContent.getContent().getBytes(), cth);

相关文章