当前位置: 首页>>代码示例>>Java>>正文


Java Request类代码示例

本文整理汇总了Java中javax.sip.message.Request的典型用法代码示例。如果您正苦于以下问题:Java Request类的具体用法?Java Request怎么用?Java Request使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Request类属于javax.sip.message包,在下文中一共展示了Request类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setAuthenticationHeaders

import javax.sip.message.Request; //导入依赖的package包/类
public void setAuthenticationHeaders(Request request) {
    SIPRequest sipRequest = (SIPRequest) request;

    String callId = sipRequest.getCallId().getCallId();

    request.removeHeader(AuthorizationHeader.NAME);
    Collection<AuthorizationHeader> authHeaders = this.cachedCredentials
            .getCachedAuthorizationHeaders(callId);
    if (authHeaders == null) {
    	if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) 
    		logger.logDebug(
                "Could not find authentication headers for " + callId);
        return;
    }

    for (AuthorizationHeader authHeader : authHeaders) {
        request.addHeader(authHeader);
    }

}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:21,代码来源:AuthenticationHelperImpl.java

示例2: processBye

import javax.sip.message.Request; //导入依赖的package包/类
public void processBye(Request request, ServerTransaction serverTransactionId) {
    try {
        logger.info("shootist:  got a bye .");
        if (serverTransactionId == null) {
            logger.info("shootist:  null TID.");
            return;
        }
        Dialog dialog = serverTransactionId.getDialog();
        logger.info("Dialog State = " + dialog.getState());
        Response response = protocolObjects.messageFactory.createResponse(200, request);
        serverTransactionId.sendResponse(response);
        logger.info("shootist:  Sending OK.");
        logger.info("Dialog State = " + dialog.getState());

    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);

    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:21,代码来源:Shootist.java

示例3: run

import javax.sip.message.Request; //导入依赖的package包/类
@Override
public void run() {
   try {
       TestCase.assertEquals ("Dialog state must be confirmed",
                DialogState.CONFIRMED,dialog.getState());



       Request byeRequest = dialog.createRequest(Request.BYE);
       ClientTransaction ctx = sipProvider.getNewClientTransaction(byeRequest);
       dialog.sendRequest(ctx);
   } catch (Exception ex) {
       TestCase.fail("Unexpected exception");
   }

}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:17,代码来源:Shootist.java

示例4: processBye

import javax.sip.message.Request; //导入依赖的package包/类
public void processBye(Request request,
        ServerTransaction serverTransactionId) {
    try {
        logger.info("shootist:  got a bye .");
        if (serverTransactionId == null) {
            logger.info("shootist:  null TID.");
            return;
        }
        Dialog dialog = serverTransactionId.getDialog();
        logger.info("Dialog State = " + dialog.getState());
        Response response = messageFactory.createResponse(200, request);
        serverTransactionId.sendResponse(response);
        logger.info("shootist:  Sending OK.");
        logger.info("Dialog State = " + dialog.getState());

    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);

    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:ClientTransactionCallingAlertTest.java

示例5: processRequest

import javax.sip.message.Request; //导入依赖的package包/类
public void processRequest(RequestEvent requestReceivedEvent) {
    Request request = requestReceivedEvent.getRequest();
    ServerTransaction serverTransactionId = requestReceivedEvent
            .getServerTransaction();

    logger.info("\n\nRequest " + request.getMethod() + " received at "
            + protocolObjects.sipStack.getStackName()
            + " with server transaction id " + serverTransactionId);

    // We are the UAC so the only request we get is the BYE.
    if (request.getMethod().equals(Request.INFO))
        processInfo(requestReceivedEvent);
    else
        TestHarness.fail("Unexpected request ! : " + request);

}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:17,代码来源:Shootist.java

示例6: setBranch

import javax.sip.message.Request; //导入依赖的package包/类
/**
 * Sets the Via branch for CANCEL or ACK requests
 * 
 * @param via
 * @param method
 * @throws ParseException
 */
private final void setBranch(Via via, String method) {
    String branch;
    if (method.equals(Request.ACK)) {
        if (getLastResponseStatusCode().intValue() >= 300) {
            branch = lastResponseTopMostVia.getBranch(); // non-2xx ACK uses
            // same branch
        } else {
            branch = Utils.getInstance().generateBranchId(); // 2xx ACK gets
            // new branch
        }
    } else if (method.equals(Request.CANCEL)) {
        branch = lastResponseTopMostVia.getBranch(); // CANCEL uses same
        // branch
    } else
        return;

    try {
        via.setBranch(branch);
    } catch (ParseException e) {
        e.printStackTrace();
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:30,代码来源:SIPDialog.java

示例7: startTransactionTimer

import javax.sip.message.Request; //导入依赖的package包/类
/**
 * @see SIPTransaction#startTransactionTimer()
 */
@Override
public void startTransactionTimer() {
    if(getMethod().equalsIgnoreCase(Request.INVITE) || getMethod().equalsIgnoreCase(Request.CANCEL) || getMethod().equalsIgnoreCase(Request.ACK)) {
        if (this.transactionTimerStarted.compareAndSet(false, true)) {
            if (sipStack.getTimer() != null && sipStack.getTimer().isStarted() ) {
                // The timer is set to null when the Stack is
                // shutting down.
                SIPStackTimerTask myTimer = new TransactionTimer();
                // Do not schedule when the stack is not alive.
                if (sipStack.getTimer() != null && sipStack.getTimer().isStarted() ) {
                    sipStack.getTimer().scheduleWithFixedDelay(myTimer, baseTimerInterval, baseTimerInterval);
                }
                myTimer = null;
            }
        }
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:21,代码来源:SIPServerTransactionImpl.java

示例8: releaseSem

import javax.sip.message.Request; //导入依赖的package包/类
/**
 * @see SIPServerTransaction#releaseSem()
 */
@Override
public void releaseSem() {
    if (this.pendingSubscribeTransaction != null) {
        /*
         * When a notify is being processed we take a lock on the subscribe to avoid racing
         * with the OK of the subscribe.
         */
        if (! sipStack.isDeliverUnsolicitedNotify()) {
            pendingSubscribeTransaction.releaseSem();
        }
    } else if (this.inviteTransaction != null && this.getMethod().equals(Request.CANCEL)) {
        /*
         * When a CANCEL is being processed we take a nested lock on the associated INVITE
         * server tx.
         */
        this.inviteTransaction.releaseSem();
    }
    super.releaseSem();
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:23,代码来源:SIPServerTransactionImpl.java

示例9: processInvite

import javax.sip.message.Request; //导入依赖的package包/类
public void processInvite(Request request, ServerTransaction st) {
    try {
        Dialog dialog = st.getDialog();
        Response response = protocolObjects.messageFactory.createResponse(
                Response.OK, request);
        ((ToHeader) response.getHeader(ToHeader.NAME))
                .setTag(((ToHeader) request.getHeader(ToHeader.NAME))
                        .getTag());

        Address address = protocolObjects.addressFactory
                .createAddress("Shootme <sip:" + myAddress + ":" + myPort
                        + ">");
        ContactHeader contactHeader = protocolObjects.headerFactory
                .createContactHeader(address);
        response.addHeader(contactHeader);
        st.sendResponse(response);
    } catch (Exception ex) {
        logger.error("unexpected exception",ex);
        SctpTest.fail("unexpected exception");
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:Shootist.java

示例10: processBye

import javax.sip.message.Request; //导入依赖的package包/类
/**
 * Process the bye request.
 */
public void processBye(RequestEvent requestEvent,
        ServerTransaction serverTransactionId) {
    Request request = requestEvent.getRequest();
    try {
        logger.info("shootme:  got a bye sending OK.");
        logger.info("shootme:  dialog = " + requestEvent.getDialog());
        logger.info("shootme:  dialogState = " + requestEvent.getDialog().getState());
        Response response = messageFactory.createResponse(200, request);
        if ( serverTransactionId != null) {
            serverTransactionId.sendResponse(response);
        }
        logger.info("shootme:  dialogState = " + requestEvent.getDialog().getState());

        this.byeSeen = true;


    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);

    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:26,代码来源:Shootme.java

示例11: createErrorAck

import javax.sip.message.Request; //导入依赖的package包/类
private final Request createErrorAck() throws SipException, ParseException {
  SIPRequest originalRequest = this.getOriginalRequest();
  if (originalRequest == null)
    throw new SipException("bad state " + getState());
  if (!isInviteTransaction()) {
    throw new SipException("Can only ACK an INVITE!");
  } else if (lastResponse == null) {
    throw new SipException("bad Transaction state");
  } else if (lastResponse.getStatusCode() < 200) {
    if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
      logger.logDebug("lastResponse = " + lastResponse);
    }
    throw new SipException("Cannot ACK a provisional response!");
  }
  return originalRequest.createErrorAck((To) lastResponse.getTo());
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:17,代码来源:SIPClientTransactionImpl.java

示例12: sendTo

import javax.sip.message.Request; //导入依赖的package包/类
private void sendTo(ServerTransaction st, Request request, int targetPort) throws Exception {
    Request newRequest = (Request) request.clone();
    
    SipURI sipUri = addressFactory.createSipURI("UA1", "127.0.0.1");
    sipUri.setPort(targetPort);
    sipUri.setLrParam();
    sipUri.setTransportParam(Shootme.transport);
    Address address = addressFactory.createAddress("client1", sipUri);
    RouteHeader rheader = headerFactory.createRouteHeader(address);

    newRequest.addFirst(rheader);
    ViaHeader viaHeader = headerFactory.createViaHeader(host, this.port, "udp", null);
    newRequest.addFirst(viaHeader);
    ClientTransaction ct1 = sipProviders.get(Shootme.transport).getNewClientTransaction(newRequest);
    sipUri = addressFactory.createSipURI("proxy", "127.0.0.1");
    address = addressFactory.createAddress("proxy", sipUri);
    sipUri.setPort(5070);
    sipUri.setLrParam();
    RecordRouteHeader recordRoute = headerFactory.createRecordRouteHeader(address);
    newRequest.addHeader(recordRoute);
    ct1.setApplicationData(st);
    ct1.sendRequest();
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:24,代码来源:Proxy.java

示例13: processBye

import javax.sip.message.Request; //导入依赖的package包/类
public void processBye(Request request,
        ServerTransaction serverTransactionId) {
    try {
        logger.info("shootist:  got a bye .");
        if (serverTransactionId == null) {
            logger.info("shootist:  null TID.");
            return;
        }
        Dialog dialog = serverTransactionId.getDialog();
        logger.info("Dialog State = " + dialog.getState());
        Response response = messageFactory.createResponse(200, request);
        serverTransactionId.sendResponse(response);
        logger.info("shootist:  Sending OK.");
        logger.info("Dialog State = " + dialog.getState());

    } catch (Exception ex) {
        TestHarness.fail(ex.getMessage());
        System.exit(0);

    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:UdpPrackTimeoutTest.java

示例14: processResponse

import javax.sip.message.Request; //导入依赖的package包/类
public void processResponse(ResponseEvent responseReceivedEvent) {
    try {
        if (responseReceivedEvent.getResponse().getStatusCode() == Response.OK) {
            this.sawOk = true;
            Dialog dialog = responseReceivedEvent.getDialog();
            long cseq = ((CSeqHeader) responseReceivedEvent.getResponse().getHeader(
                    CSeqHeader.NAME)).getSeqNumber();
            Request ack = dialog.createAck(cseq);
            dialog.sendAck(ack);
        }
    } catch (Exception ex) {
        fail("Unexpected exception");

    }

}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:17,代码来源:TransactionAlreadyExistsExceptionTest.java

示例15: getNewClientTransaction

import javax.sip.message.Request; //导入依赖的package包/类
public ClientTransaction getNewClientTransaction(Request request)
        throws TransactionUnavailableException {
  Hop hop = null;
  try {
      hop = sipStack.getNextHop((SIPRequest) request);
      if (hop == null)
          throw new TransactionUnavailableException(
                  "Cannot resolve next hop -- transaction unavailable");
  } catch (SipException ex) {
      throw new TransactionUnavailableException(
              "Cannot resolve next hop -- transaction unavailable", ex);
  }
  SIPClientTransaction newClientTransaction = createClientTransaction(request, hop);
  sipStack.addTransaction(newClientTransaction);
  return newClientTransaction;
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:17,代码来源:SipProviderImpl.java


注:本文中的javax.sip.message.Request类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。