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


Java ServerTransaction.getRequest方法代码示例

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


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

示例1: processResponse

import javax.sip.ServerTransaction; //导入方法依赖的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: processCancel

import javax.sip.ServerTransaction; //导入方法依赖的package包/类
public void processCancel(RequestEvent requestEvent,
        ServerTransaction serverTransactionId) {
    Request request = requestEvent.getRequest();
    SipProvider sipProvider = (SipProvider)requestEvent.getSource();
    try {
        logger.info("shootme:  got a cancel. " );
        // Because this is not an In-dialog request, you will get a null server Tx id here.
        if (serverTransactionId == null) {
            serverTransactionId = sipProvider.getNewServerTransaction(request);
        }
        Response response = messageFactory.createResponse(200, request);
        serverTransactionId.sendResponse(response);

        String serverTxId = ((ViaHeader)response.getHeader(ViaHeader.NAME)).getBranch();
        ServerTransaction serverTx = (ServerTransaction) this.serverTxTable.get(serverTxId);
        if ( serverTx != null && (serverTx.getState().equals(TransactionState.TRYING) ||
                serverTx.getState().equals(TransactionState.PROCEEDING))) {
            Request originalRequest = serverTx.getRequest();
            Response resp = messageFactory.createResponse(Response.REQUEST_TERMINATED,originalRequest);
            serverTx.sendResponse(resp);
        }

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

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

示例3: processResponse

import javax.sip.ServerTransaction; //导入方法依赖的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


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