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


Java Response.setHeader方法代码示例

本文整理汇总了Java中javax.sip.message.Response.setHeader方法的典型用法代码示例。如果您正苦于以下问题:Java Response.setHeader方法的具体用法?Java Response.setHeader怎么用?Java Response.setHeader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.sip.message.Response的用法示例。


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

示例1: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void processResponse(ResponseEvent responseEvent) {
    try {
        Response response = responseEvent.getResponse();
        Dialog dialog = responseEvent.getDialog();
        this.lastResponseTable.put(dialog, response);
         ServerTransaction serverTransaction = (ServerTransaction)responseEvent.getClientTransaction().getApplicationData();
        Request stRequest = serverTransaction.getRequest();
        Response newResponse = this.messageFactory.createResponse(response.getStatusCode(),stRequest);
        SipProvider provider = (SipProvider)responseEvent.getSource();
        SipProvider peerProvider = this.getPeerProvider(provider);
        ListeningPoint peerListeningPoint = peerProvider.getListeningPoint("udp");
        ContactHeader peerContactHeader = ((ListeningPointExt)peerListeningPoint).createContactHeader();
        newResponse.setHeader(peerContactHeader);
        serverTransaction.sendResponse(newResponse);
    } catch (Exception ex) {
        ex.printStackTrace();
        BackToBackUserAgentTest.fail("Unexpected exception");
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:20,代码来源:BackToBackUserAgent.java

示例2: generateChallenge

import javax.sip.message.Response; //导入方法依赖的package包/类
public void generateChallenge(HeaderFactory headerFactory, Response response, String realm  ) {
    try {
        ProxyAuthenticateHeader proxyAuthenticate = headerFactory
                .createProxyAuthenticateHeader(DEFAULT_SCHEME);
        proxyAuthenticate.setParameter("realm", realm);
        proxyAuthenticate.setParameter("nonce", generateNonce());
        proxyAuthenticate.setParameter("opaque", "");
        proxyAuthenticate.setParameter("stale", "FALSE");
        proxyAuthenticate.setParameter("algorithm", DEFAULT_ALGORITHM);
        response.setHeader(proxyAuthenticate);
    } catch (Exception ex) {
        InternalErrorHandler.handleException(ex);
    }

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

示例3: generateChallenge

import javax.sip.message.Response; //导入方法依赖的package包/类
public void generateChallenge(HeaderFactory headerFactory, Response response, String realm  ) {
    try {
        WWWAuthenticateHeader wwwAuthenticateHeader = headerFactory.createWWWAuthenticateHeader(DEFAULT_SCHEME);
        wwwAuthenticateHeader.setParameter("realm", realm);
        wwwAuthenticateHeader.setParameter("nonce", generateNonce());
        //wwwAuthenticateHeader.setParameter("opaque", "");
        //wwwAuthenticateHeader.setParameter("stale", "FALSE");
        wwwAuthenticateHeader.setParameter("algorithm", DEFAULT_ALGORITHM);
        response.setHeader(wwwAuthenticateHeader);
    } catch (Exception ex) {
        InternalErrorHandler.handleException(ex);
    }

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

示例4: sendReliableProvisionalResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
@Override
public void sendReliableProvisionalResponse(Response relResponse) throws SipException {

    /*
     * After the first reliable provisional response for a request has been acknowledged, the
     * UAS MAY send additional reliable provisional responses. The UAS MUST NOT send a second
     * reliable provisional response until the first is acknowledged.
     */
    if (this.pendingReliableResponseAsBytes != null) {
        throw new SipException("Unacknowledged response");

    } else {
        SIPResponse reliableResponse = (SIPResponse) relResponse;
        this.pendingReliableResponseAsBytes = reliableResponse.encodeAsBytes(this.getTransport());
        this.pendingReliableResponseMethod = reliableResponse.getCSeq().getMethod();
        this.pendingReliableCSeqNumber = reliableResponse.getCSeq().getSeqNumber();
    }
    /*
     * In addition, it MUST contain a Require header field containing the option tag 100rel,
     * and MUST include an RSeq header field.
     */
    RSeq rseq = (RSeq) relResponse.getHeader(RSeqHeader.NAME);
    if (relResponse.getHeader(RSeqHeader.NAME) == null) {
        rseq = new RSeq();
        relResponse.setHeader(rseq);
    }

    try {
        if(rseqNumber < 0) {
            this.rseqNumber = (int) (Math.random() * 1000);
        }
        this.rseqNumber++;
        rseq.setSeqNumber(this.rseqNumber);
        this.pendingReliableRSeqNumber = rseq.getSeqNumber();

        // start the timer task which will retransmit the reliable response
        // until the PRACK is received. Cannot send a second provisional.
        this.lastResponse = (SIPResponse) relResponse;
        if ( this.getDialog() != null  && interlockProvisionalResponses ) {
            boolean acquired = this.provisionalResponseSem.tryAcquire(1, TimeUnit.SECONDS);
            if (!acquired) {
                throw new SipException("Unacknowledged reliable response");
            }
        }
        //moved the task scheduling before the sending of the message to overcome
        // Issue 265 : https://jain-sip.dev.java.net/issues/show_bug.cgi?id=265
        this.provisionalResponseTask = new ProvisionalResponseTask();
        this.sipStack.getTimer().scheduleWithFixedDelay(provisionalResponseTask, 0,
                SIPTransactionStack.BASE_TIMER_INTERVAL);
        this.sendMessage((SIPMessage) relResponse);
    } catch (Exception ex) {
        InternalErrorHandler.handleException(ex);
    }

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

示例5: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void processResponse(ResponseEvent responseEvent) {
    try {
        Response response = responseEvent.getResponse();
        Dialog dialog = responseEvent.getDialog();
        this.lastResponseTable.put(dialog, response);
         ServerTransaction serverTransaction = (ServerTransaction)responseEvent.getClientTransaction().getApplicationData();
        if ( serverTransaction != null ) {
            Request stRequest = serverTransaction.getRequest();
            Response newResponse = this.messageFactory.createResponse(response.getStatusCode(),stRequest);
            SipProvider provider = (SipProvider)responseEvent.getSource();
            SipProvider peerProvider = this.getPeerProvider(provider);
            ListeningPoint peerListeningPoint = peerProvider.getListeningPoint("udp");
            ContactHeader peerContactHeader = ((ListeningPointExt)peerListeningPoint).createContactHeader();
            newResponse.setHeader(peerContactHeader);
            serverTransaction.sendResponse(newResponse);
            if ( ((CSeqHeader)response.getHeader(CSeqHeader.NAME)).getMethod().equals(Request.INVITE) &&
                    response.getStatusCode() == 200 ) {
                Request newRequest = dialog.createRequest(Request.INVITE);
                ListeningPointExt listeningPoint = (ListeningPointExt) provider.getListeningPoint("udp");
                ContactHeader contact = listeningPoint.createContactHeader();
                newRequest.setHeader(contact);
                ClientTransaction clientTransaction = provider.getNewClientTransaction(newRequest);
                // Send without waiting for ACK.
                dialog.sendRequest(clientTransaction);
            }
        } else {
            this.inviteOkSeen = true;
            if ( ((CSeqHeader)response.getHeader(CSeqHeader.NAME)).getMethod().equals(Request.INVITE) &&
                    response.getStatusCode() == 200){
                long cseqno = ((CSeqHeader)response.getHeader(CSeqHeader.NAME)).getSeqNumber();
                Request ack = dialog.createAck(cseqno);
                dialog.sendAck(ack);
            } else {
                if ( !((CSeqHeader)response.getHeader(CSeqHeader.NAME)).getMethod().equals(Request.INVITE)) {
                    System.out.println("Unexpected response " + response);
                    BackToBackUserAgentTest.fail("Unexpected response");
                }
            }
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        BackToBackUserAgentTest.fail("Unexpected exception");
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:45,代码来源:BackToBackUserAgent.java

示例6: processInvite

import javax.sip.message.Response; //导入方法依赖的package包/类
/**
 * Process the invite request.
 */
public void processInvite(RequestEvent requestEvent,
        ServerTransaction serverTransaction) {
    SipProvider sipProvider = (SipProvider) requestEvent.getSource();
    Request request = requestEvent.getRequest();
    try {
        logger.info("shootme: " + this.myPort + " got an Invite sending Trying");
        // logger.info("shootme: " + request);

        ServerTransaction st = requestEvent.getServerTransaction();

        if (st == null) {
            logger.info("null server tx -- getting a new one");
            st = sipProvider.getNewServerTransaction(request);
        }

        logger.info("getNewServerTransaction : " + st);

  
        Address address = addressFactory.createAddress("Shootme <sip:"
                + myAddress + ":" + myPort + ";transport=" + transport + ">");

        Response ringingResponse = messageFactory.createResponse(Response.RINGING,
                request);
        ContactHeader contactHeader = headerFactory.createContactHeader(address);
        ringingResponse.setHeader(contactHeader);
        ToHeader toHeader = (ToHeader) ringingResponse.getHeader(ToHeader.NAME);
        String toTag =  "shootme-" + myPort + "-" + new Integer(new Random().nextInt()).toString();             
        toHeader.setTag(toTag);
        if ( sendRinging ) {
            Thread.sleep(this.ringingDelay / 2);
            System.out.println("Response = " + ringingResponse);
            st.sendResponse(ringingResponse);
        }
        Dialog dialog =  st.getDialog();
        dialog.setApplicationData(st);

        this.inviteSeen = true;

        if ( okDelay > 0 ) {
            timer.schedule(new MyTimerTask(requestEvent,st,toTag), this.okDelay);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:50,代码来源:Shootme.java

示例7: processInvite

import javax.sip.message.Response; //导入方法依赖的package包/类
/**
 * Process the invite request.
 */
public void processInvite(RequestEvent requestEvent,
        ServerTransaction serverTransaction) {
    SipProvider sipProvider = (SipProvider) requestEvent.getSource();
    Request request = requestEvent.getRequest();
    try {
        logger.info("shootme: " + this.myPort + " got an Invite sending Trying");
        // logger.info("shootme: " + request);

        ServerTransaction st = requestEvent.getServerTransaction();

        if (st == null) {
            logger.info("null server tx -- getting a new one");
            st = sipProvider.getNewServerTransaction(request);
        }

        logger.info("getNewServerTransaction : " + st);

  
        Address address = addressFactory.createAddress("Shootme <sip:"
                + myAddress + ":" + myPort + ">");

        Response ringingResponse = messageFactory.createResponse(Response.RINGING,
                request);
        ContactHeader contactHeader = headerFactory.createContactHeader(address);
        ringingResponse.setHeader(contactHeader);
        ToHeader toHeader = (ToHeader) ringingResponse.getHeader(ToHeader.NAME);
        String toTag =  "shootme-" + myPort + "-" + new Integer(new Random().nextInt()).toString();             
        toHeader.setTag(toTag);
        if ( sendRinging ) {
            Thread.sleep(this.ringingDelay / 2);
            st.sendResponse(ringingResponse);
        }
        Dialog dialog =  st.getDialog();
        dialog.setApplicationData(st);

        this.inviteSeen = true;

        if ( okDelay > 0 ) {
            timer.schedule(new MyTimerTask(requestEvent,st,toTag), this.okDelay);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:49,代码来源:Shootme.java


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