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

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

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

Request介绍

暂无

代码示例

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

public void execute(RequestEvent event) {
    Request request = event.getRequest();
    final String calleeCallId = ((CallIdHeader) request
        .getHeader(CallIdHeader.NAME)).getCallId();
    String method = request.getMethod();
    if (Request.BYE.equals(method)) {
      handleBye(calleeCallId, request);
    }
  }
}

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

public void onTimerEvent(TimerEvent event, ActivityContextInterface aci) {
  try {
    DialogActivity dialog = (DialogActivity)aci.getActivity(); 
    Request request = dialog.createRequest(Request.BYE);
    request.addHeader(getContactHeader());
    ClientTransaction clientTransaction = sipFactoryProvider.getNewClientTransaction(request);
    clientTransaction.sendRequest();
  } catch (Exception ex) {
    ex.printStackTrace();
  }
}

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

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

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

public void processRequest(RequestEvent requestReceivedEvent) {
  Request request = requestReceivedEvent.getRequest();
  ServerTransaction serverTransactionId = requestReceivedEvent
      .getServerTransaction();
  String viaBranch = ((ViaHeader)(request.getHeaders(ViaHeader.NAME).next())).getParameter("branch");
  LOG.debug("Request: {}", request.getMethod()); 
  LOG.debug("Server Transaction Id: {}", serverTransactionId);
  LOG.debug("Received From Branch: {}", viaBranch);
  if (request.getMethod().equals(Request.NOTIFY)) {
    processNotify(requestReceivedEvent, serverTransactionId);
  } 
}

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

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

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

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

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

while (headerNames.hasNext()) {
    String headerName = headerNames.next();
    if ( reoriginatedRequest.getHeader(headerName) == null) {
      ListIterator<SIPHeader> iterator = challengedRequest.getHeaders(headerName);
      while (iterator.hasNext()) { reoriginatedRequest.addHeader(iterator.next()); }
reoriginatedRequest.removeHeader(AuthorizationHeader.NAME);
reoriginatedRequest.removeHeader(ProxyAuthorizationHeader.NAME);
CSeqHeader cSeq = (CSeqHeader) reoriginatedRequest.getHeader((CSeqHeader.NAME));
try {
  cSeq.setSeqNumber(cSeq.getSeqNumber() + 1l);
  SipURI sipUri = (SipURI) reoriginatedRequest.getRequestURI();
  sipUri.setMAddrParam(hop.getHost());
  if ( hop.getPort() != -1 ) sipUri.setPort(hop.getPort());
SipURI requestUri = (SipURI) challengedTransaction.getRequest().getRequestURI();
while (authHeaders.hasNext()) {
  authHeader = (WWWAuthenticateHeader) authHeaders.next();
    URI uri = reoriginatedRequest.getRequestURI();
    sipDomain = credHash.getSipDomain();
    authorization = this.getAuthorization(reoriginatedRequest
        .getMethod(), uri.toString(),
        (reoriginatedRequest.getContent() == null) ? "" : new String(
        reoriginatedRequest.getRawContent()), authHeader, credHash);
  } else {
    UserCredentials userCreds = ((AccountManager) this.accountManager).getCredentials(challengedTransaction, realm);

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

newRequest.removeHeader(ViaHeader.NAME);	
ViaHeader viaHeader = JainSipUtils.createViaHeader(
    getSipNetworkInterfaceManager(), newRequest, branch, null);
newRequest.addHeader(viaHeader);
final FromHeader newFromHeader = (FromHeader) newRequest.getHeader(FromHeader.NAME); 
((ToHeader) newRequest.getHeader(ToHeader.NAME))
    .removeParameter("tag");
newRequest.removeHeader(RecordRouteHeader.NAME);
if(!Request.REGISTER.equalsIgnoreCase(newRequest.getMethod())) {
  try {
    if(!Request.REGISTER.equalsIgnoreCase(newRequest.getMethod())) {
      if(JainSipUtils.CONTACT_HEADER_METHODS.contains(newRequest.getMethod())) {
        String fromName = null;
        String displayName = ((MessageExt)newRequest).getFromHeader().getAddress().getDisplayName();
        if(newRequest.getHeader(ContactHeader.NAME) != null && 
          ((ContactHeader)newRequest.getHeader(ContactHeader.NAME)).getAddress().getURI() instanceof javax.sip.address.SipURI) {
          fromName = ((javax.sip.address.SipURI)((MessageExt)newRequest).getFromHeader().getAddress().getURI()).getUser();
        newRequest.removeHeader(ContactHeader.NAME);
        if(contactHeader != null) {
          newRequest.addHeader(contactHeader);

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

public static void optimizeRouteHeaderAddressForInternalRoutingrequest(SipConnector sipConnector, Request request, MobicentsSipSession session,  SipFactoryImpl sipFactoryImpl, String transport) {
  RouteHeader rh = (RouteHeader) request.getHeader(RouteHeader.NAME);
  javax.sip.address.URI uri = null;
  if(rh != null) {
    uri = rh.getAddress().getURI();
  } else {
    uri = request.getRequestURI();
  }
  if(uri.isSipURI()) {
    javax.sip.address.SipURI sipUri = (javax.sip.address.SipURI) uri;
    optimizeUriForInternalRoutingRequest(sipConnector, sipUri, session, sipFactoryImpl, transport);
  }
}

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

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

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

final String method = clonedRequest.getMethod();
final ProxyImpl proxy = (ProxyImpl) proxyBranch.getProxy(); 
final SipFactoryImpl sipFactoryImpl = proxy.getSipFactoryImpl();
RouteHeader rHeader = (RouteHeader) clonedRequest.getHeader(RouteHeader.NAME);
if(rHeader != null) {
  String nextApp = ((javax.sip.address.SipURI)rHeader.getAddress().getURI()).getParameter(MessageDispatcher.RR_PARAM_APPLICATION_NAME);
        clonedRequest.removeFirst(RouteHeader.NAME);
      rHeader = (RouteHeader) clonedRequest.getHeader(RouteHeader.NAME);
  if(clonedRequest.getRequestURI().isSipURI()) {
    outboundTransport = ((javax.sip.address.SipURI)clonedRequest.getRequestURI()).getTransportParam();
    if(destination != null && destination.isSipURI()) {
      String destinationTransport = ((SipURI)destination).getTransportParam();
Via via = ((Via)clonedRequest.getHeader(Via.NAME));
String inboundTransport = via.getTransport();
if(inboundTransport == null) inboundTransport = ListeningPoint.UDP;
  Header route = clonedRequest.getHeader("Route");
  if(route == null || 
    clonedRequest.setRequestURI(((URIImpl)destination).getURI());
    clonedRequest.removeHeader(ViaHeader.NAME);
    clonedRequest.removeHeader(RecordRouteHeader.NAME);

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

if(methodRequest.getHeader(ContactHeader.NAME) != null) {
    FromHeader from = (FromHeader) methodRequest.getHeader(FromHeader.NAME);
    String displayName = from.getAddress().getDisplayName();
    String userName = null;
    methodRequest.setHeader(contactHeader);
  } catch (Exception e) {
    logger.error("Can not create contact header for subsequent request " + method + " for session " + key, e);
ListIterator<ViaHeader> viaHeaders = methodRequest.getHeaders(ViaHeader.NAME);				
if(viaHeaders != null && viaHeaders.hasNext()) {
  ViaHeader viaHeader = viaHeaders.next();
methodRequest.removeHeader(ViaHeader.NAME);
ViaHeader viaHeader = JainSipUtils.createViaHeader(
    sipFactory.getSipNetworkInterfaceManager(), methodRequest, branch, outboundInterface);
methodRequest.addHeader(viaHeader);
  javax.sip.address.URI requestUri = (javax.sip.address.URI) request.getRequestURI().clone();					
  try {
    request.setMethod(method);
  } catch (ParseException e) {
    throw new IllegalArgumentException("Unexpected exception happened on setting method " + method, e);
  request.setRequestURI(requestUri);
  ((MessageExt)request).setApplicationData(null);

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

clonedRequest.addHeader(viaHeader);
  } else {				
    if(SipRouteModifier.NO_ROUTE.equals(sipRouteModifier)) {
    clonedRequest.addHeader(viaHeader);
  clonedRequest.addHeader(viaHeader);	 			
  .getHeader(MaxForwardsHeader.NAME);
if (maxForwardsHeader == null) {
  maxForwardsHeader = SipFactoryImpl.headerFactory.createMaxForwardsHeader(JainSipUtils.MAX_FORWARD_HEADER_VALUE);
  clonedRequest.addHeader(maxForwardsHeader);
} else {
  if(maxForwardsHeader.getMaxForwards() - 1 > 0) {
} else if ( clonedRequest.getMethod().equals("ACK") ) {
  if(logger.isInfoEnabled()) {
    logger.info("Sending the ACK through the dialog " + clonedRequest);
} else {
  Request dialogRequest=
    dialog.createRequest(clonedRequest.getMethod());
  Object content=clonedRequest.getContent();
  if (content!=null) {
    ContentTypeHeader contentTypeHeader= (ContentTypeHeader)
      clonedRequest.getHeader(ContentTypeHeader.NAME);
    if (contentTypeHeader!=null) {
      dialogRequest.setContent(content,contentTypeHeader);

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

URI requestURI = request.getRequestURI();
JoinHeader joinHeader = (JoinHeader)request.getHeader(JoinHeader.NAME);
ReplacesHeader replacesHeader = (ReplacesHeader)request.getHeader(ReplacesHeader.NAME);
if(joinHeader != null || replacesHeader != null) {
  if(logger.isDebugEnabled()) {
  if(!Request.INVITE.equals(request.getMethod())) {
    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

final String requestMethod = request.getMethod();
    .getHeader(RouteHeader.NAME);
  String method = requestEvent.getRequest().getMethod();
  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);
  if(logger.isDebugEnabled()) {
    try {
      if(request.getHeader(MaxForwardsHeader.NAME) == null){
        request.setHeader(SipFactoryImpl.headerFactory.createMaxForwardsHeader(70));
    request.removeFirst(RouteHeader.NAME);
    sipServletRequest.setPoppedRoute(routeHeader);
    final Parameters poppedAddress = (Parameters)routeHeader.getAddress().getURI();
    if(poppedAddress.getParameter(MessageDispatcher.RR_PARAM_PROXY_APP) != null || 
        (request.getRequestURI() instanceof javax.sip.address.SipURI && ((Parameters)request.getRequestURI()).getParameter(MessageDispatcher.RR_PARAM_PROXY_APP) != null)) {
      if(logger.isDebugEnabled()) {
        logger.debug("the request is for a proxy application, thus it is a subsequent request ");
  logger.error("Unexpected exception while processing request " + request,e);
  if(!Request.ACK.equalsIgnoreCase(request.getMethod())) {
    MessageDispatcher.sendErrorResponse(this, Response.SERVER_INTERNAL_ERROR, requestTransaction, request, sipProvider);

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

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

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

public void processRequest(RequestEvent requestEvent) {
  Request request = requestEvent.getRequest();
  ServerTransaction serverTransactionId = requestEvent.getServerTransaction();
  LOG.debug("Request: {}", request.getMethod()); 
  LOG.debug("Server Transaction Id: {}", serverTransactionId);
  if (request.getMethod().equals(Request.SUBSCRIBE)) {
    processSubscribe(requestEvent, serverTransactionId);
  } else if (request.getMethod().equals(Request.PUBLISH)) {
    processPublish(requestEvent, serverTransactionId);
  } else {
    LOG.debug("Received expected request with method: {}. No further processing done", request.getMethod());
  }
}

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

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

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

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");
if(!Request.INVITE.equals(getTransaction().getRequest().getMethod())) {
  throw new Rel100Exception(Rel100Exception.NOT_INVITE);
  prackRequest.removeHeader(ViaHeader.NAME);
  ViaHeader viaHeader = JainSipUtils.createViaHeader(
      sipFactoryImpl.getSipNetworkInterfaceManager(), prackRequest, branch, session.getOutboundInterface());
  prackRequest.addHeader(viaHeader);
  ListIterator<RouteHeader> routeHeaders = prackRequest.getHeaders(RouteHeader.NAME);
  prackRequest.removeHeader(RouteHeader.NAME);
  while (routeHeaders.hasNext()) {
    RouteHeader routeHeader = routeHeaders.next();
      prackRequest.addHeader(routeHeader);

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

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

相关文章