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


Java Dialog.createRequest方法代码示例

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


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

示例1: processAck

import javax.sip.Dialog; //导入方法依赖的package包/类
public void processAck(Request request, ServerTransaction tid) {
    try {
        logger.info("Got an ACK! sending bye : " + tid);
        if (tid != null) {
            Dialog dialog = tid.getDialog();
            TlsTest.assertSame("dialog id mismatch", dialog,this.dialog);
            Request bye = dialog.createRequest(Request.BYE);
            MaxForwardsHeader mf = protocolObjects.headerFactory
                    .createMaxForwardsHeader(10);
            bye.addHeader(mf);
            ClientTransaction ct = provider.getNewClientTransaction(bye);
            dialog.sendRequest(ct);
            this.byeSent = true;
        }
    } catch (Exception ex) {
        logger.error("unexpected exception",ex);
        TlsTest.fail("unexpected exception");

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

示例2: processAck

import javax.sip.Dialog; //导入方法依赖的package包/类
public void processAck(Request request, ServerTransaction tid) {
    try {
        logger.info("Got an ACK! sending bye : " + tid);
        if (tid != null) {
            Dialog dialog = tid.getDialog();
            SctpTest.assertSame("dialog id mismatch", dialog,this.dialog);
            Request bye = dialog.createRequest(Request.BYE);
            MaxForwardsHeader mf = protocolObjects.headerFactory
                    .createMaxForwardsHeader(10);
            bye.addHeader(mf);
            ClientTransaction ct = provider.getNewClientTransaction(bye);
            dialog.sendRequest(ct);
            this.byeSent = true;
        }
    } catch (Exception ex) {
        logger.error("unexpected exception",ex);
        SctpTest.fail("unexpected exception");

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

示例3: processAck

import javax.sip.Dialog; //导入方法依赖的package包/类
/** Process the ACK request. Send the bye and complete the call flow.
*/
public void processAck(
    RequestEvent requestEvent,
    ServerTransaction serverTransaction) {
    SipProvider sipProvider = (SipProvider) requestEvent.getSource();
    try {
        // System.out.println("shootme: got an ACK " );
        // maybe a late arriving ack.
        if (serverTransaction == null) return;
        Dialog dialog = serverTransaction.getDialog();
            dialog = serverTransaction.getDialog();
        Request byeRequest = dialog.createRequest(Request.BYE);
        ClientTransaction tr =
            sipProvider.getNewClientTransaction(byeRequest);
        dialog.sendRequest(tr);
    } catch (Exception ex) {
        ex.printStackTrace();
        fail("unexpected exception");
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:Shootme.java

示例4: processNotify

import javax.sip.Dialog; //导入方法依赖的package包/类
public void processNotify(Request request,
        ServerTransaction serverTransactionId) {
    try {
        System.out.println("subsciber:  got a notify .");
        if (serverTransactionId == null) {
            System.out.println("subsciber:  null TID.");
            return;
        }
        Dialog dialog = serverTransactionId.getDialog();
        System.out.println("Dialog State = " + dialog.getState());
        Response response = messageFactory.createResponse(200, request);
        serverTransactionId.sendResponse(response);
        System.out.println("subsciber:  Sending OK.");
        System.out.println("Dialog State = " + dialog.getState());

        // Unsubscribe to the Subscription. Note that if you do not unsubscribe the dialog will
        // live on and eventually you will run out of memory.

        Request unsub = dialog.createRequest(Request.SUBSCRIBE);
        ExpiresHeader expiresHeader = headerFactory
                .createExpiresHeader(0);
        unsub.addHeader(expiresHeader);

        EventHeader eventHeader = null;
        eventHeader = headerFactory.createEventHeader("reg");
        unsub.addHeader(eventHeader);

        ClientTransaction ct = sipProvider.getNewClientTransaction(unsub);
        ct.sendRequest();

        dialog.delete();

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

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

示例5: processResponse

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

示例6: processResponse

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

示例7: processResponse

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

示例8: processResponse

import javax.sip.Dialog; //导入方法依赖的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());
            TlsTest.assertTrue( "Secure URI",
                    ((SipURI)ackRequest.getRequestURI()).isSecure() );
            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);
        TlsTest.fail("unexpected exception");
    }

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

示例9: processResponse

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

示例10: processResponse

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

示例11: processResponse

import javax.sip.Dialog; //导入方法依赖的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("Dialog state is " + dialog.getState());

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

                dialog.sendAck(ackRequest);

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

                // Proxy will fork. I will accept the second dialog
                // but not the first.

                SipProvider sipProvider = (SipProvider) responseReceivedEvent
                        .getSource();

                Request infoRequest = dialog.createRequest(Request.INFO);
                ClientTransaction ct = sipProvider
                        .getNewClientTransaction(infoRequest);
                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,代码行数:59,代码来源:Shootist.java


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