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


Java Response.getStatusCode方法代码示例

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


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

示例1: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void processResponse(ResponseEvent responseReceivedEvent) {
    // System.out.println("Got a response");
    Response response = (Response) responseReceivedEvent.getResponse();
    Transaction tid = responseReceivedEvent.getClientTransaction();

    // System.out.println("Response received with client transaction id "
    // + tid + ":\n" + response);

    System.out.println("GOT RESPONSE: " + response.getStatusCode());
    try {
        if (response.getStatusCode() == Response.OK && ((CSeqHeader) response.getHeader(CSeqHeader.NAME)).getMethod().equals(Request.INVITE)) {

            Dialog dialog = tid.getDialog();
            
            Request request = tid.getRequest();
            dialog.sendAck(request);
        }

    } catch (Exception ex) {
        ex.printStackTrace();
        TxTimeoutTest.fail("Shootme: Failed on process response: " + response.getStatusCode(), ex);
    }

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

示例2: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void processResponse(ResponseEvent responseReceivedEvent) {
    Response response = (Response) responseReceivedEvent.getResponse();
    System.out.println("GOT RESPONSE:" + response.getStatusCode());
    this.statusCode = response.getStatusCode();
    if(responseReceivedEvent.getClientTransaction() == null) {
    	return;
    }
    try {
        if (response.getStatusCode() == Response.OK
                && ((CSeqHeader) response.getHeader(CSeqHeader.NAME))
                        .getMethod().equals(Request.INVITE)) {            	
        	System.out.println("Not Sending ACK to test dialog timeout");            	
        }
    } catch (Exception ex) {
        ex.printStackTrace();

        TxTimeoutTest.fail(
                "Shootist: Exception on process respons/send info", ex);
    }

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

示例3: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void processResponse(ResponseEvent responseReceivedEvent) {
    // System.out.println("Got a response");
    Response response = (Response) responseReceivedEvent.getResponse();
    Transaction tid = responseReceivedEvent.getClientTransaction();

    // System.out.println("Response received with client transaction id "
    // + tid + ":\n" + response);

    System.out.println("GOT RESPONSE: " + response.getStatusCode());
    try {
        if (response.getStatusCode() == Response.OK && ((CSeqHeader) response.getHeader(CSeqHeader.NAME)).getMethod().equals(Request.INVITE)) {

            Dialog dialog = tid.getDialog();
            
            Request request = tid.getRequest();
            dialog.sendAck(request);
        }

    } catch (Exception ex) {
        ex.printStackTrace();
        DialogTimeoutTest.fail("Shootme: Failed on process response: " + response.getStatusCode(), ex);
    }

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

示例4: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void processResponse(ResponseEvent responseReceivedEvent) {
    Response response = (Response) responseReceivedEvent.getResponse();
    System.out.println("GOT RESPONSE:" + response.getStatusCode());
    if(responseReceivedEvent.getClientTransaction() == null) {
    	return;
    }
    try {
        if (response.getStatusCode() == Response.OK
                && ((CSeqHeader) response.getHeader(CSeqHeader.NAME))
                        .getMethod().equals(Request.INVITE)) {            	
        	System.out.println("Not Sending ACK to test dialog timeout");            	
        }
    } catch (Exception ex) {
        ex.printStackTrace();

        DialogTimeoutTest.fail(
                "Shootist: Exception on process respons/send info", ex);
    }

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

示例5: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void processResponse(ResponseEvent responseReceivedEvent) {
    // System.out.println("Got a response");
    Response response = (Response) responseReceivedEvent.getResponse();
    Transaction tid = responseReceivedEvent.getClientTransaction();

    // System.out.println("Response received with client transaction id "
    // + tid + ":\n" + response);

    System.out.println("GOT RESPONSE: " + response.getStatusCode());
    try {
        if (response.getStatusCode() == Response.OK && ((CSeqHeader) response.getHeader(CSeqHeader.NAME)).getMethod().equals(Request.INVITE)) {

            Dialog dialog = tid.getDialog();
            Request request = tid.getRequest();
            dialog.sendAck(request);
        }

    } catch (Exception ex) {
        ex.printStackTrace();
        DialogTimeoutTest.fail("Shootme: Failed on process response: " + response.getStatusCode(), ex);
    }

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

示例6: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void processResponse(ResponseEvent responseReceivedEvent) {
         logger.info("Got a response");

         Response response = (Response) responseReceivedEvent.getResponse();
         Transaction tid = responseReceivedEvent.getClientTransaction();

         logger.info("Response received with client transaction id " + tid
                 + ":\n" + response.getStatusCode());
         if (tid != null) {
	logger.info("Dialog = " + responseReceivedEvent.getDialog());
	logger.info("Dialog State is "
			+ responseReceivedEvent.getDialog().getState());
}
         SipProvider provider = (SipProvider) responseReceivedEvent.getSource();

         try {
             if (response.getStatusCode() == Response.OK
                     && ((CSeqHeader) response.getHeader(CSeqHeader.NAME))
                             .getMethod().equals(Request.INVITE)) {

                 Dialog dialog = responseReceivedEvent.getDialog();
                 CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);
                 Request ackRequest = dialog.createAck(cseq.getSeqNumber());
                 logger.info("Ack request to send = " + ackRequest);
                 logger.info("Sending ACK");
                 dialog.sendAck(ackRequest);
             }
         } catch (Exception ex) {
             logger.error(ex);
             ex.printStackTrace();
             AckReTransmissionTest.fail("unexpected exception");
         }

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

示例7: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void processResponse(ResponseEvent responseReceivedEvent) {
         logger.info("Got a response");

         Response response = (Response) responseReceivedEvent.getResponse();
         Transaction tid = responseReceivedEvent.getClientTransaction();

         logger.info("Response received with client transaction id " + tid
                 + ":\n" + response.getStatusCode());
         if (tid != null) {
	logger.info("Dialog = " + responseReceivedEvent.getDialog());
	logger.info("Dialog State is "
			+ responseReceivedEvent.getDialog().getState());
}
         SipProvider provider = (SipProvider) responseReceivedEvent.getSource();

         try {
         	if (response.getStatusCode() == Response.OK) {
         		if(((CSeqHeader) response.getHeader(CSeqHeader.NAME))
         				.getMethod().equals(Request.INVITE)) {
         			okToInviteReceived = true;
         		}
         	}
         } catch (Exception ex) {
             logger.error(ex);
             ex.printStackTrace();
             fail("unexpected exception");
         }

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

示例8: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public synchronized void processResponse(ResponseEvent responseReceivedEvent) {
    logger.info("Got a response");
    Response response = responseReceivedEvent.getResponse();
    ClientTransaction tid = responseReceivedEvent.getClientTransaction();
    CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);

    logger.info("Response received : Status Code = " + response.getStatusCode() + " " + cseq);
    logger.info("Response = " + response + " class=" + response.getClass());

    Dialog dialog = responseReceivedEvent.getDialog();
    TestCase.assertNotNull(dialog);

    if (tid != null)
        logger.info("transaction state is " + tid.getState());
    else
        logger.info("transaction = " + tid);

    logger.info("Dialog = " + dialog);

    logger.info("Dialog state is " + dialog.getState());

    try {
        if (response.getStatusCode() == Response.OK) {
            if (cseq.getMethod().equals(Request.INVITE)) {
                TestCase.assertEquals(DialogState.CONFIRMED, dialog.getState());

            } else {
                logger.info("Response method = " + cseq.getMethod());
            }
        }
    } catch (Throwable ex) {
        ex.printStackTrace();
        // System.exit(0);
    }

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

示例9: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public synchronized void processResponse(ResponseEvent responseReceivedEvent) {
    Response response = (Response) responseReceivedEvent.getResponse();
    Transaction tid = responseReceivedEvent.getClientTransaction();

    if (response.getStatusCode() != 200) {
        this.notifyCount--;
    } else {
        System.out.println("Notify Count = " + this.notifyCount);
    }

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

示例10: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public synchronized void processResponse(ResponseEvent responseReceived) {
    try {            
        ResponseEventExt responseReceivedEvent = (ResponseEventExt) responseReceived;
        Response response = (Response) responseReceivedEvent.getResponse();
        ClientTransaction tid = responseReceivedEvent.getClientTransaction();
        CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);

        logger.info("Response received : Status Code = "
                + response.getStatusCode() + " " + cseq);
        logger.info("Response = " + response + " class=" + response.getClass() );            

        Dialog dialog = responseReceivedEvent.getDialog();     
        this.forkedDialogs.add(dialog);
        if(createDialogAfterRequest) {
            TestCase.assertNull( dialog );
            return;
        } else {
            TestCase.assertNotNull( dialog );
        }
        System.out.println("original Tx " + responseReceivedEvent.getOriginalTransaction());            
        if (tid != null)
            logger.info("transaction state is " + tid.getState());
        else
            logger.info("transaction = " + tid);

        logger.info("Dialog = " + dialog);
        logger.info("Dialog state is " + dialog.getState());
        if ( response.getStatusCode() == Response.OK && cseq.getMethod().equals(Request.INVITE) ) {
            Request ackRequest = dialog.createAck(cseq.getSeqNumber());
            dialog.sendAck(ackRequest);
            this.timer.schedule( new SendBye(dialog),500);
        }
                   
    } catch (Throwable ex) {
        ex.printStackTrace();
        // System.exit(0);
    }

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

示例11: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void processResponse(ResponseEvent responseReceivedEvent) {
    logger.info("Got a response");
    Response response = (Response) responseReceivedEvent.getResponse();
    ClientTransaction tid = responseReceivedEvent.getClientTransaction();
    CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);

    logger.info("Response received : Status Code = "
            + response.getStatusCode() + " " + cseq);


    if (tid == null) {
        logger.info("Stray response -- dropping ");
        return;
    }
    logger.info("transaction state is " + tid.getState());
    logger.info("Dialog = " + tid.getDialog());
    logger.info("Dialog State is " + tid.getDialog().getState());
    SipProvider provider = (SipProvider) responseReceivedEvent.getSource();
    AbstractRouterTestCase.assertEquals("Provider is not equal to the original proivder",
            provider, sipProvider);

    try {
        if (response.getStatusCode() == Response.OK) {
            if (cseq.getMethod().equals(Request.INVITE)) {
                Request ackRequest = dialog.createAck(cseq.getSeqNumber());
                logger.info("Sending ACK");
                dialog.sendAck(ackRequest);
                this.gotInviteOK = true;
            }
        }
    } catch (Exception ex) {
        AbstractRouterTestCase.fail(ex.getMessage());

    }

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

示例12: sendReliableProvisionalResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void sendReliableProvisionalResponse(Response relResponse)
        throws SipException {
    if (!this.isServer()) {
        throw new SipException("Not a Server Dialog");
    }

    SIPResponse sipResponse = (SIPResponse) relResponse;

    if (relResponse.getStatusCode() == 100)
        throw new SipException(
                "Cannot send 100 as a reliable provisional response");

    if (relResponse.getStatusCode() / 100 > 2)
        throw new SipException(
                "Response code is not a 1xx response - should be in the range 101 to 199 ");

    /*
     * Do a little checking on the outgoing response.
     */
    if (sipResponse.getToTag() == null) {
        throw new SipException(
                "Badly formatted response -- To tag mandatory for Reliable Provisional Response");
    }
    ListIterator requireList = (ListIterator) relResponse
            .getHeaders(RequireHeader.NAME);
    boolean found = false;

    if (requireList != null) {

        while (requireList.hasNext() && !found) {
            RequireHeader rh = (RequireHeader) requireList.next();
            if (rh.getOptionTag().equalsIgnoreCase("100rel")) {
                found = true;
            }
        }
    }

    if (!found) {
        Require require = new Require("100rel");
        relResponse.addHeader(require);
        if (logger.isLoggingEnabled(LogWriter.TRACE_DEBUG)) {
            logger
                    .logDebug(
                            "Require header with optionTag 100rel is needed -- adding one");
        }

    }

    SIPServerTransaction serverTransaction = (SIPServerTransaction) this
            .getFirstTransactionInt();
    /*
     * put into the dialog table before sending the response so as to avoid
     * race condition with PRACK
     */
    this.setLastResponse(serverTransaction, sipResponse);

    this.setDialogId(sipResponse.getDialogId(true));

    serverTransaction.sendReliableProvisionalResponse(relResponse);

    this.startRetransmitTimer(serverTransaction, relResponse);

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

示例13: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public synchronized void processResponse(ResponseEvent responseEvent) {
    try {
        Response response = responseEvent.getResponse();
        CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);
        logger.info("ClientTxID = " + responseEvent.getClientTransaction() + " client tx id "
                + ((ViaHeader) response.getHeader(ViaHeader.NAME)).getBranch()
                + " CSeq header = " + response.getHeader(CSeqHeader.NAME) + " status code = "
                + response.getStatusCode());

        // JvB: stateful proxy MUST NOT forward 100 Trying
        if (response.getStatusCode() == 100)
            return;

        if (response.getStatusCode() == Response.LOOP_DETECTED) {
        	logger.info("Saw a LOOP DETECTED response");
            this.loopDetectedSeen = true;
        }
        if (cseq.getMethod().equals(Request.INVITE)) {
            ClientTransaction ct = responseEvent.getClientTransaction();
            if (ct != null) {
                ServerTransaction st = (ServerTransaction) ct.getApplicationData();

                // Strip the topmost via header
                Response newResponse = (Response) response.clone();
                newResponse.removeFirst(ViaHeader.NAME);
                // The server tx goes to the terminated state.

                st.sendResponse(newResponse);

            } else {
                logger.debug("Discarding response - no transaction found!");
            }
        } else {
            // this is the OK for the cancel.
            logger.info("Got a non-invite response " + response);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("unexpected exception");
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:42,代码来源:Proxy.java

示例14: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public void processResponse(ResponseEvent responseReceivedEvent) {
    logger.info("Got a response");
    Response response = (Response) responseReceivedEvent.getResponse();
    Transaction tid = responseReceivedEvent.getClientTransaction();

    if(tid != null) {
     logger.info("Response received with client transaction id "
             + tid + ":\n" + response.getStatusCode() +
             " cseq = " + response.getHeader(CSeqHeader.NAME) + 
             " dialog " + tid.getDialog());
    } else {
    	logger.info("Response received with client transaction id "
             + tid + ":\n" + response.getStatusCode() +
             " cseq = " + response.getHeader(CSeqHeader.NAME) + 
             " dialog " + responseReceivedEvent.getDialog());
    }
    
    // Filter retransmissions for slow machines
    if(tid == null) return;

    CSeqHeader cseq = (CSeqHeader) response.getHeader( CSeqHeader.NAME );
    if (cseq.getMethod().equals(Request.INVITE)) {

        try {
            sendNotify( response.getStatusCode(), response.getReasonPhrase() );
        } catch (Exception e1) {
            TestHarness.fail("Failed to send notify, because of " + e1.getMessage());
        }

        if (response.getStatusCode() == 200 ) {
            try {
                Request ack = tid.getDialog().createAck( cseq.getSeqNumber() );
                tid.getDialog().sendAck( ack );

                // kill it right away
                if ( tid.getDialog().getState() != DialogState.TERMINATED ) {
                	Request bye = tid.getDialog()
				.createRequest(Request.BYE);
		tid.getDialog().sendRequest(
				mySipProvider.getNewClientTransaction(bye));
                }
            } catch (Exception e) {
            	logger.error("Caught exception",e);
                TestHarness.fail("Failed to send BYE request, because of " + e.getMessage());
            }
        }
    }


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

示例15: 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


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