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


Java SipProvider.getNewServerTransaction方法代码示例

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


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

示例1: processInvite

import javax.sip.SipProvider; //导入方法依赖的package包/类
/**
 * Process the invite request.
 */
public void processInvite(RequestEvent requestEvent, ServerTransaction serverTransaction) {
    try {
        // System.out.println("ProcessInvite");
        Request request = requestEvent.getRequest();
        SipProvider sipProvider = (SipProvider) requestEvent.getSource();
        // Note you need to create the Server Transaction
        // before the listener returns but you can delay sending the
        // response

        ServerTransaction st = sipProvider.getNewServerTransaction(request);

        TTask ttask = new TTask(requestEvent, st);
        int ttime = 100;

        new Timer().schedule(ttask, ttime);
    } catch (Exception ex) {
        ex.printStackTrace();
        DialogTimeoutTest.fail("Shootme: Failed on process INVITE", ex);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:24,代码来源:Shootme.java

示例2: processInvite

import javax.sip.SipProvider; //导入方法依赖的package包/类
private void processInvite( RequestEvent re )
{
    SipProvider provider = (SipProvider) re.getSource();
    ServerTransaction st = re.getServerTransaction();
    try {
        if (st==null) st = provider.getNewServerTransaction( re.getRequest() );
        Response r = messageFactory.createResponse( 100 , re.getRequest());
        st.sendResponse( r );
        r = messageFactory.createResponse( 180 , re.getRequest());
        r.addHeader( (ContactHeader) contactHeader.clone() );
        ((ToHeader) r.getHeader("To")).setTag( "inv_res" );
        st.sendResponse( r );
        Thread.sleep( 500 );
        r = messageFactory.createResponse( 200, re.getRequest() );
        r.addHeader( (ContactHeader) contactHeader.clone() );
        ((ToHeader) r.getHeader("To")).setTag( "inv_res" );
        st.sendResponse( r );
    } catch (Throwable t) {
        t.printStackTrace();
        TestHarness.fail( "Throwable:" + t.getLocalizedMessage() );
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:23,代码来源:Referrer.java

示例3: processCancel

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

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

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

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

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

示例5: 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 {
        System.out.println("shootme: got an Invite sending Trying");
        // System.out.println("shootme: " + request);
        Response response = messageFactory.createResponse(Response.RINGING,
                request);
        ServerTransaction st = requestEvent.getServerTransaction();

        if (st == null) {
            st = sipProvider.getNewServerTransaction(request);
        }
        dialog = st.getDialog();

        st.sendResponse(response);

        this.okResponse = messageFactory.createResponse(Response.OK,
                request);
        Address address = addressFactory.createAddress("Shootme <sip:"
                + myAddress + ":" + myPort + ">");
        ContactHeader contactHeader = headerFactory
                .createContactHeader(address);
        response.addHeader(contactHeader);
        ToHeader toHeader = (ToHeader) okResponse.getHeader(ToHeader.NAME);
        toHeader.setTag("4321"); // Application is supposed to set.
        okResponse.addHeader(contactHeader);
        this.inviteTid = st;
        // Defer sending the OK to simulate the phone ringing.
        // Answered in 1 second ( this guy is fast at taking calls)
        this.inviteRequest = request;

        new Timer().schedule(new MyTimerTask(this), 1000);
    } catch (Exception ex) {
        ex.printStackTrace();
        System.exit(0);
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:43,代码来源:NoToTagOn1xxDialogLeakTest.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)) {
            // Attach a record route header with NO transport here.
            ServerTransaction st = null;
            if (requestEvent.getServerTransaction() == null) {
                st = sipProvider.getNewServerTransaction(request);

            }                
            this.sendTo(st,request,5080 );
                        

        } 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);
            String transport = ((SipURI) newRequest.getRequestURI()).getTransportParam();
            sipProviders.get(transport).sendRequest(newRequest);
        }

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

}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:33,代码来源: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 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

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

        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

示例9: 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: " + 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

示例10: processNotify

import javax.sip.SipProvider; //导入方法依赖的package包/类
private void processNotify(RequestEvent requestEvent,
        ServerTransaction serverTransactionId) {
    SipProvider provider = (SipProvider) requestEvent.getSource();
    Request notify = requestEvent.getRequest();
    if ( notify.getMethod().equals("NOTIFY") ) try {
        logger.info("referer:  got a NOTIFY count  " + ++this.count + ":\n" + notify );
        if (serverTransactionId == null) {
            logger.info("referer:  null TID.");
            serverTransactionId = provider.getNewServerTransaction(notify);
        }
        Dialog dialog = serverTransactionId.getDialog();
        logger.info("Dialog = " + dialog);

        TestHarness.assertTrue("Dialog should not be null", dialog != null);
        logger.info("Dialog State = " + dialog.getState());

        Response response = messageFactory.createResponse(200, notify);
        // SHOULD add a Contact
        ContactHeader contact = (ContactHeader) contactHeader.clone();
        ((SipURI)contact.getAddress().getURI()).setParameter( "id", "sub" );
        response.addHeader( contact );
        logger.info("Transaction State = " + serverTransactionId.getState());
        serverTransactionId.sendResponse(response);
        logger.info("Dialog State = " + dialog.getState());
        SubscriptionStateHeader subscriptionState = (SubscriptionStateHeader) notify
                .getHeader(SubscriptionStateHeader.NAME);

        // Subscription is terminated?
        String state = subscriptionState.getState();
        if (state.equalsIgnoreCase(SubscriptionStateHeader.TERMINATED)) {
            dialog.delete();
        } else {
            logger.info("Referer: state now " + state);
        }
    } catch (Exception ex) {
        TestHarness.fail("Failed processing notify, because of " + ex);

    } else {
        TestHarness.fail( "Unexpected request type" );
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:42,代码来源:Referrer.java

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

示例12: processInvite

import javax.sip.SipProvider; //导入方法依赖的package包/类
/**
 * Process the invite request.
 */
public void processInvite(RequestEvent requestEvent,
        ServerTransaction serverTransaction) {
    inviteReceived = true;
    SipProvider sipProvider = (SipProvider) requestEvent.getSource();
    Request request = requestEvent.getRequest();
    try {
        logger.info("shootme: got an Invite sending Trying");
        // logger.info("shootme: " + request);
        Response response = messageFactory.createResponse(Response.TRYING,
                request);
        ServerTransaction st = requestEvent.getServerTransaction();

        if (st == null) {
            st = sipProvider.getNewServerTransaction(request);
        }
        dialog = st.getDialog();

        st.sendResponse(response);

        // reliable provisional response.

        Response okResponse = messageFactory.createResponse(PRACK_CODE,
                request);
        ToHeader toHeader = (ToHeader) okResponse.getHeader(ToHeader.NAME);
        this.toTag = "4321";
        toHeader.setTag(toTag); // Application is supposed to set.
        this.inviteTid = st;
        this.inviteRequest = request;

        logger.info("sending reliable provisional response.");

        RequireHeader requireHeader = headerFactory
                .createRequireHeader("100rel");
        okResponse.addHeader(requireHeader);
        dialog.sendReliableProvisionalResponse(okResponse);
    } catch (Exception ex) {
      ex.printStackTrace();
        TestHarness.fail(ex.getMessage());

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

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

示例14: processNotify

import javax.sip.SipProvider; //导入方法依赖的package包/类
public synchronized void processNotify(RequestEvent requestEvent,
        ServerTransaction serverTransactionId) {
    SipProvider provider = (SipProvider) requestEvent.getSource();
    Request notify = requestEvent.getRequest();
    try {
        logger.info("subscriber:  got a notify count  " + this.count++);
        if (serverTransactionId == null) {
            logger.info("subscriber:  null TID.");
            serverTransactionId = provider.getNewServerTransaction(notify);
        }
        Dialog dialog = serverTransactionId.getDialog();
        logger.info("Dialog = " + dialog);

        if (dialog != null) {
            logger.info("Dialog State = " + dialog.getState());
        }

        Response response = messageFactory.createResponse(200, notify);
        // SHOULD add a Contact
        ContactHeader contact = (ContactHeader) contactHeader.clone();
        ((SipURI) contact.getAddress().getURI()).setParameter("id", "sub");
        response.addHeader(contact);
        logger.info("Transaction State = " + serverTransactionId.getState());
        serverTransactionId.sendResponse(response);
        if (dialog != null) {
            logger.info("Dialog State = " + dialog.getState());
        }
        SubscriptionStateHeader subscriptionState = (SubscriptionStateHeader) notify
                .getHeader(SubscriptionStateHeader.NAME);

        // Subscription is terminated?
        String state = subscriptionState.getState();
        if (state.equalsIgnoreCase(SubscriptionStateHeader.TERMINATED)) {
            dialog.delete();
        } else {
            logger.info("Subscriber: state now " + state);
        }
        this.notifySeen = true;

    } catch (Exception ex) {
        ex.printStackTrace();
        logger.error("Unexpected exception", ex);
        fail("Unexpected exception");

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

示例15: 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: " + 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 + ";transport=" + transport + ">");

        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);
            System.out.println("Response = " + ringingResponse);
            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,代码行数:50,代码来源:Shootme.java


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