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


Java SipProvider.getListeningPoint方法代码示例

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


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

示例1: processResponse

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

import javax.sip.SipProvider; //导入方法依赖的package包/类
private void sendInviteOK(RequestEvent requestEvent, ServerTransaction inviteTid, String toTag) {
    try {
        logger.info("sendInviteOK: " + inviteTid);
        if (inviteTid.getState() != TransactionState.COMPLETED) {
            logger.info("shootme: Dialog state before OK: "
                    + inviteTid.getDialog().getState());

            SipProvider sipProvider = (SipProvider) requestEvent.getSource();
            Request request = requestEvent.getRequest();
            Response okResponse = messageFactory.createResponse(Response.OK,
                    request);
                ListeningPoint lp = sipProvider.getListeningPoint(transport);
            int myPort = lp.getPort();


            ((ToHeader)okResponse.getHeader(ToHeader.NAME)).setTag(toTag);


            Address address = addressFactory.createAddress("Shootme <sip:"
                    + myAddress + ":" + myPort + ">");
            ContactHeader contactHeader = headerFactory
                    .createContactHeader(address);
            okResponse.addHeader(contactHeader);
            inviteTid.sendResponse(okResponse);
            logger.info("shootme: Dialog state after OK: "
                    + inviteTid.getDialog().getState());
            TestCase.assertEquals( DialogState.CONFIRMED , inviteTid.getDialog().getState() );
        } else {
            logger.info("semdInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:35,代码来源:Shootme.java

示例3: sendInviteOK

import javax.sip.SipProvider; //导入方法依赖的package包/类
private void sendInviteOK(RequestEvent requestEvent, ServerTransaction inviteTid, String toTag) {
    try {
        
        logger.info("sendInviteOK: " + inviteTid);
        if (inviteTid.getState() != TransactionState.COMPLETED) {
            logger.info("shootme: Dialog state before OK: "
                    + inviteTid.getDialog().getState());

            SipProvider sipProvider = (SipProvider) requestEvent.getSource();
            Request request = requestEvent.getRequest();
            Response okResponse = messageFactory.createResponse(Response.OK,
                    request);
                ListeningPoint lp = sipProvider.getListeningPoint(transport);
            int myPort = lp.getPort();


            ((ToHeader)okResponse.getHeader(ToHeader.NAME)).setTag(toTag);


            Address address = addressFactory.createAddress("Shootme <sip:"
                    + myAddress + ":" + myPort + ">");
            ContactHeader contactHeader = headerFactory
                    .createContactHeader(address);
            okResponse.addHeader(contactHeader);
            inviteTid.sendResponse(okResponse);
            logger.info("shootme: Dialog state after OK: "
                    + inviteTid.getDialog().getState());
            TestCase.assertEquals( DialogState.CONFIRMED , inviteTid.getDialog().getState() );
        } else {
            logger.info("semdInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:36,代码来源:Shootme.java

示例4: sendInviteOK

import javax.sip.SipProvider; //导入方法依赖的package包/类
private void sendInviteOK(RequestEvent requestEvent, ServerTransaction inviteTid, String toTag) {
    try {
        logger.info("sendInviteOK: " + inviteTid);
        if (inviteTid.getState() == TransactionState.PROCEEDING) {
            logger.info("shootme: Dialog state before OK: " + inviteTid.getDialog().getState());
            System.err.println("shootme: Dialog state before OK: " + inviteTid.getDialog().getState());
            SipProvider sipProvider = (SipProvider) requestEvent.getSource();
            Request request = requestEvent.getRequest();
            Response okResponse = messageFactory.createResponse(Response.OK, request);
            ListeningPoint lp = sipProvider.getListeningPoint(transport);
            int myPort = lp.getPort();

            ((ToHeader) okResponse.getHeader(ToHeader.NAME)).setTag(toTag);

            Address address = addressFactory.createAddress("Shootme <sip:" + myAddress + ":" + myPort + ">");
            ContactHeader contactHeader = headerFactory.createContactHeader(address);
            okResponse.addHeader(contactHeader);
            inviteTid.sendResponse(okResponse);
            logger.info("shootme: Dialog state after OK: " + inviteTid.getDialog().getState());
            TestCase.assertEquals(DialogState.CONFIRMED, inviteTid.getDialog().getState());
        } else {
            logger.info("semdInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
            System.err.println("sentInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:29,代码来源:Shootme.java

示例5: sendInviteOK

import javax.sip.SipProvider; //导入方法依赖的package包/类
private void sendInviteOK(RequestEvent requestEvent, ServerTransaction inviteTid, String toTag) {
    try {
        logger.info("sendInviteOK: " + inviteTid);
        if (inviteTid.getState() != TransactionState.COMPLETED) {
            logger.info("shootme: Dialog state before OK: "
                    + inviteTid.getDialog().getState());

            SipProvider sipProvider = (SipProvider) requestEvent.getSource();
            Request request = requestEvent.getRequest();
            Response okResponse = messageFactory.createResponse(Response.OK,
                    request);
                ListeningPoint lp = sipProvider.getListeningPoint(transport);
            int myPort = lp.getPort();


            ((ToHeader)okResponse.getHeader(ToHeader.NAME)).setTag(toTag);


            Address address = addressFactory.createAddress("Shootme <sip:"
                    + myAddress + ":" + myPort + ";transport=" + transport+ ">");
            ContactHeader contactHeader = headerFactory
                    .createContactHeader(address);
            okResponse.addHeader(contactHeader);
            inviteTid.sendResponse(okResponse);
            logger.info("shootme: Dialog state after OK: "
                    + inviteTid.getDialog().getState());
            TestCase.assertEquals( DialogState.CONFIRMED , inviteTid.getDialog().getState() );
        } else {
            logger.info("semdInviteOK: inviteTid = " + inviteTid + " state = " + inviteTid.getState());
        }
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:35,代码来源:Shootme.java

示例6: processRequest

import javax.sip.SipProvider; //导入方法依赖的package包/类
public void processRequest(RequestEvent requestEvent) {
    try {
        Request request = requestEvent.getRequest();
        SipProvider sipProvider = (SipProvider) requestEvent.getSource();
        this.inviteServerTxProvider = sipProvider;
        if (request.getMethod().equals(Request.INVITE)) {

            ListeningPoint lp = sipProvider.getListeningPoint(transport);
            String host = lp.getIPAddress();
            int port = lp.getPort();

            ServerTransaction st = null;
            if (requestEvent.getServerTransaction() == null) {
                st = sipProvider.getNewServerTransaction(request);

            }
            
            for ( int i = 0; i < ntargets; i++ ) {
                this.sendTo(st,request,5080 + i);
            }

         
           

        } else {
            // Remove the topmost route header
            // The route header will make sure it gets to the right place.
            logger.info("proxy: Got a request " + request.getMethod());
            Request newRequest = (Request) request.clone();
            newRequest.removeFirst(RouteHeader.NAME);
            sipProvider.sendRequest(newRequest);
        }

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

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

示例7: processInvite

import javax.sip.SipProvider; //导入方法依赖的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 =  new Integer(new Random().nextInt()).toString();
        toHeader.setTag(toTag);
        if ( sendRinging ) {
            ringingResponse.addHeader(contactHeader);
            st.sendResponse(ringingResponse);
        }
        Dialog dialog =  st.getDialog();
        dialog.setApplicationData(st);

        this.inviteSeen = true;

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

示例8: processInvite

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

示例9: processResponse

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

示例10: processInvite

import javax.sip.SipProvider; //导入方法依赖的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();
        inviteTid = st;
        if (st == null) {
            logger.info("null server tx -- getting a new one");
            st = sipProvider.getNewServerTransaction(request);
        }

        logger.info("getNewServerTransaction : " + 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);


        ContactHeader contactHeader = headerFactory.createContactHeader(address);
        response.addHeader(contactHeader);

        String toTag = new Integer(new Random().nextInt()).toString();

        Dialog dialog = st.getDialog();
        inviteDialog = dialog;
        inviteDialog.terminateOnBye(true);
        dialog.setApplicationData(st);

        this.inviteSeen = true;

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


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