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


Java Response.getHeader方法代码示例

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


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

示例1: 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 {

        if ( serverTransaction == null) {
            serverTransaction = sipProvider.getNewServerTransaction(request);
        }
        Response okResponse = messageFactory.createResponse(Response.OK,
                request);
        Address address = addressFactory.createAddress("Shootme <sip:"
                + myAddress + ":" + myPort + ">");
        ContactHeader contactHeader = headerFactory
                .createContactHeader(address);
        ToHeader toHeader = (ToHeader) okResponse.getHeader(ToHeader.NAME);
        toHeader.setTag("4321"); // Application is supposed to set.
        okResponse.addHeader(contactHeader);
        serverTransaction.sendResponse(okResponse); // Send it through the transaction layer.


    } catch (Exception ex) {
        ex.printStackTrace();
        fail("Unexpected exception ");
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:30,代码来源:RejectOutOfSequenceMessageTest.java

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

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

示例4: processPrack

import javax.sip.message.Response; //导入方法依赖的package包/类
private void processPrack(RequestEvent requestEvent,
        ServerTransaction serverTransactionId) {
    prackRequestReceived = true;
    try {
        logger.info("shootme: got an PRACK! ");
        logger.info("Dialog State = " + dialog.getState());

        /**
         * JvB: First, send 200 OK for PRACK
         */
        Request prack = requestEvent.getRequest();
        Response prackOk = messageFactory.createResponse(200, prack);
        serverTransactionId.sendResponse(prackOk);

        /**
         * Send a 200 OK response to complete the 3 way handshake for the
         * INIVTE.
         */
        Response response = messageFactory.createResponse(200,
                inviteRequest);
        ToHeader to = (ToHeader) response.getHeader(ToHeader.NAME);
        to.setTag(this.toTag);
        Address address = addressFactory.createAddress("Shootme <sip:"
                + myAddress + ":" + myPort + ">");
        ContactHeader contactHeader = headerFactory
                .createContactHeader(address);
        response.addHeader(contactHeader);
        inviteTid.sendResponse(response);
    } catch (Exception ex) {
        TestHarness.fail(ex.getMessage());
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:33,代码来源:UdpPrackTimeoutTest.java

示例5: 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 {


        Response okResponse = messageFactory.createResponse(Response.OK,
                request);
        FromHeader from = (FromHeader) okResponse.getHeader(FromHeader.NAME);
        from.removeParameter("tag");
        Address address = addressFactory.createAddress("Shootme <sip:"
                + myAddress + ":" + myPort + ">");
        ContactHeader contactHeader = headerFactory
                .createContactHeader(address);
        ToHeader toHeader = (ToHeader) okResponse.getHeader(ToHeader.NAME);
        toHeader.setTag("4321"); // Application is supposed to set.
        okResponse.addHeader(contactHeader);
        sipProvider.sendResponse(okResponse); // Send it through the Provider.


    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:30,代码来源:RejectInvalidResponseTest.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: got an Invite sending RINGING");
        // logger.info("shootme: " + request);
        Response response = messageFactory.createResponse(180, request);
        ToHeader toHeader = (ToHeader) response
                .getHeader(ToHeader.NAME);
        toHeader.setTag("4321"); // Application is supposed to set.
        Address address = addressFactory.createAddress("Shootme <sip:"
                + myAddress + ":" + myPort + ">");
        ContactHeader contactHeader = headerFactory
                .createContactHeader(address);
        response.addHeader(contactHeader);
        ServerTransaction st = requestEvent.getServerTransaction();

        if (st == null) {
            st = sipProvider.getNewServerTransaction(request);
            logger.info("Created a new server transaction for "
                    + request.getMethod() + " serverTransaction = "
                    + st);
        }
        inviteTid = st;

        dialog = st.getDialog();

        st.sendResponse(response);

    } catch (Exception ex) {
        logger.error(ex);
        fail(unexpectedException);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:39,代码来源:CancelEventTest.java

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

示例8: processResponse

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

    System.out.println("Response received : Status Code = "
            + response.getStatusCode() + " " + cseq);
    if (tid == null) {
        System.out.println("Stray response -- dropping ");
        return;
    }
    System.out.println("transaction state is " + tid.getState());
    System.out.println("Dialog = " + tid.getDialog());
    System.out.println("Dialog State is " + tid.getDialog().getState());

    try {
        if (response.getStatusCode() == Response.OK) {
            if (cseq.getMethod().equals(Request.INVITE)) {
                Dialog dialog = inviteTid.getDialog();
                Request ackRequest = dialog.createAck( cseq.getSeqNumber() );
                System.out.println("Sending ACK");
                dialog.sendAck(ackRequest);
            } else if (cseq.getMethod().equals(Request.CANCEL)) {
                if (dialog.getState() == DialogState.CONFIRMED) {
                    // oops cancel went in too late. Need to hang up the
                    // dialog.
                    System.out
                            .println("Sending BYE -- cancel went in too late !!");
                    Request byeRequest = dialog.createRequest(Request.BYE);
                    ClientTransaction ct = sipProvider
                            .getNewClientTransaction(byeRequest);
                    dialog.sendRequest(ct);
                }
            }
        } else if (response.getStatusCode() == Response.PROXY_AUTHENTICATION_REQUIRED
                || response.getStatusCode() == Response.UNAUTHORIZED) {
            AuthenticationHelper authenticationHelper = 
                ((SipStackExt) sipStack).getAuthenticationHelper(new AccountManagerImpl(), headerFactory);
            
            inviteTid = authenticationHelper.handleChallenge(response, tid, sipProvider, 5);
         
            inviteTid.sendRequest();
          
            invco++;
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);
    }

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

示例9: 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: 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);

        String txId = ((ViaHeader)request.getHeader(ViaHeader.NAME)).getBranch();
        this.serverTxTable.put(txId, st);

        // Create the 100 Trying response.
        Response response = messageFactory.createResponse(Response.TRYING,
                request);
            ListeningPoint lp = sipProvider.getListeningPoint(transport);
        int myPort = lp.getPort();

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

        // Add a random sleep to stagger the two OK's for the benifit of implementations
        // that may not be too good about handling re-entrancy.
        int timeToSleep = (int) ( Math.random() * 1000);

        Thread.sleep(timeToSleep);

        st.sendResponse(response);

        Response ringingResponse = messageFactory.createResponse(Response.RINGING,
                request);
        ContactHeader contactHeader = headerFactory.createContactHeader(address);
        response.addHeader(contactHeader);
        ToHeader toHeader = (ToHeader) ringingResponse.getHeader(ToHeader.NAME);
        String toTag;
        if ( ((ToHeader) ringingResponse.getHeader(ToHeader.NAME)).getTag() == null ) {
            toTag =  new Integer(new Random().nextInt()).toString();
            toHeader.setTag(toTag);
        } else {
            toTag = ((ToHeader) ringingResponse.getHeader(ToHeader.NAME)).getTag();
        }
        if ( sendRinging ) {
            ringingResponse.addHeader(contactHeader);
            st.sendResponse(ringingResponse);
        }
        Dialog dialog =  st.getDialog();
        dialog.setApplicationData(st);

        this.inviteSeen = true;

        this.sendInviteOK(requestEvent,st,toTag);
    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:68,代码来源:Shootme.java

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

示例11: 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 {
        serverTransaction = sipProvider.getNewServerTransaction(request);
        dialog = (DialogExt) sipProvider.getNewDialog(serverTransaction);
        dialog.disableSequenceNumberValidation();
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    try {


        Response okResponse = messageFactory.createResponse(Response.OK,
                request);
        FromHeader from = (FromHeader) okResponse.getHeader(FromHeader.NAME);
        from.removeParameter("tag");
        Address address = addressFactory.createAddress("Shootme <sip:"
                + myAddress + ":" + myPort + ">");
        ContactHeader contactHeader = headerFactory
                .createContactHeader(address);
        ToHeader toHeader = (ToHeader) okResponse.getHeader(ToHeader.NAME);
        toHeader.setTag("4321"); // Application is supposed to set.

        FromHeader fromHeader = (FromHeader)okResponse.getHeader(FromHeader.NAME);
        fromHeader.setTag("12345");
        okResponse.addHeader(contactHeader);
        serverTransaction.sendResponse(okResponse);


    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:44,代码来源:SIPEventInterceptorTest.java

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

示例13: 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("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();

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

            // Request cancel = inviteTid.createCancel();
            // ClientTransaction ct =
            // sipProvider.getNewClientTransaction(cancel);
            Dialog dialog = tid.getDialog();
            Request ackRequest = dialog.createAck(cseq.getSeqNumber());
            logger.info("Ack request to send = " + ackRequest);
            logger.info("Sending ACK");
            dialog.sendAck(ackRequest);

            // Send a Re INVITE but this time force it
            // to use UDP as the transport. Else, it will
            // Use whatever transport was used to create
            // the dialog.
            if (reInviteCount == 0) {
                Request inviteRequest = dialog
                        .createRequest(Request.INVITE);
                Thread.sleep(100);
                ClientTransaction ct = provider
                        .getNewClientTransaction(inviteRequest);
                dialog.sendRequest(ct);
                reInviteCount++;
            } else {
                this.okReceived = true;
            }

        } else if (response.getStatusCode() == Response.OK
                && ((CSeqHeader) response.getHeader(CSeqHeader.NAME))
                        .getMethod().equals(Request.BYE)) {
            this.byeOkRecieved = true;
        }
    } catch (Exception ex) {
        logger.error(ex);
        SctpTest.fail("unexpected exception");
    }

}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:59,代码来源:Shootist.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();

    logger.info("Response received with client transaction id " + tid + ":\n"
            + response.getStatusCode());
    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();

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

            // Request cancel = inviteTid.createCancel();
            // ClientTransaction ct =
            // sipProvider.getNewClientTransaction(cancel);
            Dialog dialog = tid.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);

            Thread.sleep(100);
          
            Request inviteRequest = dialog.createRequest(Request.INVITE);
            ((SipURI) inviteRequest.getRequestURI()).removeParameter("transport");
            ((ViaHeader) inviteRequest.getHeader(ViaHeader.NAME)).setTransport("udp");
            inviteRequest.addHeader(contactHeader);
            MaxForwardsHeader mf = protocolObjects.headerFactory
                    .createMaxForwardsHeader(10);
            inviteRequest.addHeader(mf);
             ClientTransaction ct = provider.getNewClientTransaction(inviteRequest);
            dialog.sendRequest(ct);
            reInviteCount++;
            logger.info("RE-INVITE sent");

        } else if (response.getStatusCode() == Response.BUSY_HERE) {
            this.busyHereReceived = true;
            TestCase.assertEquals("Dialog State must be CONFIRMED", dialog.getState(), DialogState.CONFIRMED);
        }
    } catch (Exception ex) {
        ex.printStackTrace();

        logger.error(ex);
        ReInviteBusyTest.fail("unexpceted exception");
    }

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

示例15: processResponse

import javax.sip.message.Response; //导入方法依赖的package包/类
public synchronized 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);
        logger.info("Response = " + response + " class=" + response.getClass() );

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

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

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

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

        try {
            if (response.getStatusCode() == Response.OK) {
                if (cseq.getMethod().equals(Request.INVITE)) {
                	/*
                	 * Can get a late arriving response.
                	 */
//                    TestHarness.assertEquals( DialogState.CONFIRMED, dialog.getState());


                    Request ackRequest = dialog.createAck(cseq
                            .getSeqNumber());

                    TestHarness.assertNotNull( ackRequest.getHeader( MaxForwardsHeader.NAME ) );

                    // Proxy will fork. I will accept the second dialog
                    // but not the first.
                    this.forkedDialogs.add(dialog);
                    logger.info("Sending ACK");
                    dialog.sendAck(ackRequest);
                    if ( dialog.getState() == DialogState.TERMINATED ) {
                    	return;
                    }
                    if ( forkedDialogs.size() == 2 ) {
                      
                        TestHarness.assertTrue(
                                "Dialog state should be CONFIRMED", dialog
                                        .getState() == DialogState.CONFIRMED);
                        this.ackedDialog = dialog;

                        // TestHarness.assertNotNull( "JvB: Need CT to find original dialog", tid );

                    } else {

                        // Kill the first dialog by sending a bye.
                        SipProvider sipProvider = (SipProvider) responseReceivedEvent
                                .getSource();
                        Request byeRequest = dialog.createRequest(Request.BYE);
                        ClientTransaction ct = sipProvider
                                .getNewClientTransaction(byeRequest);
                        dialog.sendRequest(ct);
                    }


                } else {
                    logger.info("Response method = " + cseq.getMethod());
                }
            } else if ( response.getStatusCode() == Response.RINGING ) {
                //TestHarness.assertEquals( DialogState.EARLY, dialog.getState() );
            }
        } catch (Throwable ex) {
            ex.printStackTrace();
            // System.exit(0);
        }

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


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