• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ToHeader类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



ToHeader类属于javax.sip.header包,在下文中一共展示了ToHeader类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getHeadersToOmmitOnResponseCopy

import javax.sip.header.ToHeader; //导入依赖的package包/类
private static Set<String> getHeadersToOmmitOnResponseCopy() {
	if (HEADERS_TO_OMMIT_ON_RESPONSE_COPY == null) {
		final Set<String> set = new HashSet<String>();
		set.add(RouteHeader.NAME);
		set.add(RecordRouteHeader.NAME);
		set.add(ViaHeader.NAME);
		set.add(CallIdHeader.NAME);
		set.add(CSeqHeader.NAME);
		set.add(ContactHeader.NAME);
		set.add(FromHeader.NAME);
		set.add(ToHeader.NAME);
		set.add(ContentLengthHeader.NAME);
		HEADERS_TO_OMMIT_ON_RESPONSE_COPY = Collections.unmodifiableSet(set);
	}
	return HEADERS_TO_OMMIT_ON_RESPONSE_COPY;
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:17,代码来源:TestCall.java


示例2: sendMultipleContactRegistration

import javax.sip.header.ToHeader; //导入依赖的package包/类
public void sendMultipleContactRegistration() throws Exception {
     	Address fromAddress = addressFactory.createAddress("[email protected]:5070");
     	ContactHeader contactHeader1 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5070"));
 		ContactHeader contactHeader2 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5080"));
 		
 		
CallIdHeader callId = provider.getNewCallId();			
CSeqHeader cSeq = headerFactory.createCSeqHeader(1l, Request.REGISTER);
FromHeader from = headerFactory.createFromHeader(fromAddress, "1234");
ToHeader to = headerFactory.createToHeader(addressFactory.createAddress("[email protected]"+host+":"+SERVER_PORT), null);
List via = Arrays.asList(((ListeningPointImpl)provider.getListeningPoint(testProtocol)).getViaHeader());			
MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(10);
 		
 		URI requestURI = addressFactory.createURI("sip:[email protected]"+host+":"+SERVER_PORT);
 		Request request = messageFactory.createRequest(requestURI, Request.REGISTER, callId, cSeq, from, to, via, maxForwards);
 		    		
 		request.setRequestURI(requestURI);
 		request.addHeader(contactHeader1);
 		request.addHeader(contactHeader2);
 		ClientTransaction ctx = this.provider.getNewClientTransaction(request);
 		ctx.sendRequest();
     }
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:23,代码来源:MultipleContactsTest.java


示例3: processInvite

import javax.sip.header.ToHeader; //导入依赖的package包/类
/**
 * Process the invite request.
 */
public void processInvite(RequestEvent requestEvent,
        ServerTransaction serverTransaction) {
    SipProvider sipProvider = (SipProvider) requestEvent.getSource();
    Request request = requestEvent.getRequest();
    this.sawInvite = true;
    try {

        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);
        sipProvider.sendResponse(okResponse); // Send it through the
                                                // Provider.

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


示例4: sendInviteWithRPort

import javax.sip.header.ToHeader; //导入依赖的package包/类
public void sendInviteWithRPort() throws Exception {
     	Address fromAddress = addressFactory.createAddress("[email protected]:5070");
     	ContactHeader contactHeader1 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5070"));
 		ContactHeader contactHeader2 = headerFactory.createContactHeader(addressFactory.createAddress("sip:[email protected]:5080"));
 		
 		
CallIdHeader callId = provider.getNewCallId();			
CSeqHeader cSeq = headerFactory.createCSeqHeader(1l, Request.INVITE);
FromHeader from = headerFactory.createFromHeader(fromAddress, "1234");
ToHeader to = headerFactory.createToHeader(addressFactory.createAddress("[email protected]"+host+":"+SERVER_PORT), null);
ViaHeader via = ((ListeningPointImpl)provider.getListeningPoint(testProtocol)).getViaHeader();
via.setRPort();
List vias = Arrays.asList(via);			
MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(10);
 		
 		URI requestURI = addressFactory.createURI("sip:[email protected]"+host+":"+SERVER_PORT);
 		Request request = messageFactory.createRequest(requestURI, Request.INVITE, callId, cSeq, from, to, vias, maxForwards);
 		System.out.println(request);
 		assertTrue(request.toString().indexOf("rport=") == -1);    		
 		
 		request.setRequestURI(requestURI);
 		request.addHeader(contactHeader1);
 		request.addHeader(contactHeader2);
 		ClientTransaction ctx = this.provider.getNewClientTransaction(request);
 		ctx.sendRequest();
     }
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:27,代码来源:ViaRPortTest.java


示例5: processInvite

import javax.sip.header.ToHeader; //导入依赖的package包/类
public void processInvite(Request request, ServerTransaction st) {
    try {
        Dialog dialog = st.getDialog();
        Response response = protocolObjects.messageFactory.createResponse(
                Response.OK, request);
        ((ToHeader) response.getHeader(ToHeader.NAME))
                .setTag(((ToHeader) request.getHeader(ToHeader.NAME))
                        .getTag());

        Address address = protocolObjects.addressFactory
                .createAddress("Shootme <sips:" + myAddress + ":" + myPort
                        + ">");
        ContactHeader contactHeader = protocolObjects.headerFactory
                .createContactHeader(address);
        response.addHeader(contactHeader);
        st.sendResponse(response);
    } catch (Exception ex) {
        logger.error("unexpected exception",ex);
        TlsTest.fail("unexpected exception");
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:Shootist.java


示例6: processInvite

import javax.sip.header.ToHeader; //导入依赖的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


示例7: processInvite

import javax.sip.header.ToHeader; //导入依赖的package包/类
public void processInvite(Request request, ServerTransaction st) {
    try {
        Dialog dialog = st.getDialog();
        Response response = protocolObjects.messageFactory.createResponse(
                Response.OK, request);
        ((ToHeader) response.getHeader(ToHeader.NAME))
                .setTag(((ToHeader) request.getHeader(ToHeader.NAME))
                        .getTag());

        Address address = protocolObjects.addressFactory
                .createAddress("Shootme <sip:" + myAddress + ":" + myPort
                        + ">");
        ContactHeader contactHeader = protocolObjects.headerFactory
                .createContactHeader(address);
        response.addHeader(contactHeader);
        st.sendResponse(response);
    } catch (Exception ex) {
        logger.error("unexpected exception",ex);
        SctpTest.fail("unexpected exception");
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:Shootist.java


示例8: getAddress

import javax.sip.header.ToHeader; //导入依赖的package包/类
public String getAddress() {
    if (dialog.getState() != null) {
        return dialog.getRemoteParty().getURI().toString();
    }
    else {
        if (dialog.isServer()) {
            FromHeader fromHeader = (FromHeader)initialRequest
                    .getHeader(FromHeader.NAME);
            return fromHeader.getAddress().getURI().toString();
        }
        else {
            ToHeader toHeader = (ToHeader)initialRequest
                    .getHeader(ToHeader.NAME);
            return toHeader.getAddress().getURI().toString();
        }
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:18,代码来源:Call.java


示例9: attachToTag

import javax.sip.header.ToHeader; //导入依赖的package包/类
/**
 * Generates a ToTag (the containingDialog's hashCode())and attaches it to
 * response's ToHeader.
 *
 * @param response         the response that is to get the ToTag.
 * @param containingDialog the Dialog instance that is to extract a unique Tag value
 *                         (containingDialog.hashCode())
 */
public void attachToTag(Response response, Dialog containingDialog) {
    ToHeader to = (ToHeader) response.getHeader(ToHeader.NAME);
    if (to == null) {
        fireCommunicationsError(new CommunicationsException(
                "No TO header found in, attaching a to tag is therefore impossible"));
    }
    try {
        if (to.getTag() == null || to.getTag().trim().length() == 0) {

            // the containing dialog may be null (e.g. when called by
            // sendNotImplemented). Attach sth else in that case.
            // Bug Report - Joe Provino - SUN Microsystems
            int toTag = containingDialog != null ? containingDialog
                    .hashCode() : (int) System.currentTimeMillis();

            to.setTag(Integer.toString(toTag));
        }
    }
    catch (ParseException ex) {
        fireCommunicationsError(new CommunicationsException(
                "Failed to attach a TO tag to an outgoing response"));
    }
}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:32,代码来源:SipManager.java


示例10: sendInviteOK

import javax.sip.header.ToHeader; //导入依赖的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


示例11: sendInviteOK

import javax.sip.header.ToHeader; //导入依赖的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


示例12: sendInviteOK

import javax.sip.header.ToHeader; //导入依赖的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


示例13: processPrack

import javax.sip.header.ToHeader; //导入依赖的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


示例14: sendInviteOK

import javax.sip.header.ToHeader; //导入依赖的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


示例15: processInvite

import javax.sip.header.ToHeader; //导入依赖的package包/类
public void processInvite(Request request, ServerTransaction st) {
    try {
        this.reInviteReceivedCount++;
        Dialog dialog = st.getDialog();
        logger.info("shootist received RE INVITE. Sending BUSY_HERE");
        assertEquals("Dialog state must in confirmed state ",DialogState.CONFIRMED,dialog.getState());
        
        Thread.sleep(300);
        
        Response response = protocolObjects.messageFactory.createResponse(Response.BUSY_HERE,
                request);
        ((ToHeader) response.getHeader(ToHeader.NAME)).setTag(((ToHeader) request
                .getHeader(ToHeader.NAME)).getTag());

        Address address = protocolObjects.addressFactory.createAddress("Shootme <sip:"
                + myAddress + ":" + myPort + ">");
        ContactHeader contactHeader = protocolObjects.headerFactory
                .createContactHeader(address);
        response.addHeader(contactHeader);
        st.sendResponse(response);
        assertEquals("Dialog state must be in confirmed state ",DialogState.CONFIRMED,dialog.getState());
        ReInviteBusyTest.assertEquals("Dialog for reinvite must match original dialog",
                dialog, this.dialog);

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


示例16: processInvite

import javax.sip.header.ToHeader; //导入依赖的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


示例17: processInvite

import javax.sip.header.ToHeader; //导入依赖的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


示例18: processInvite

import javax.sip.header.ToHeader; //导入依赖的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


示例19: processInvite

import javax.sip.header.ToHeader; //导入依赖的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


示例20: processInvite

import javax.sip.header.ToHeader; //导入依赖的package包/类
public void processInvite(Request request, ServerTransaction st) {
    try {
        this.reInviteReceivedCount++;
        Dialog dialog = st.getDialog();
        logger.info("shootist received RE INVITE. Sending BUSY_HERE");
        assertEquals("Dialog state must in confirmed state ",DialogState.CONFIRMED,dialog.getState());
        
        Thread.sleep(300);
        
        Response response = protocolObjects.messageFactory.createResponse(Response.BUSY_HERE,
                request);
        ((ToHeader) response.getHeader(ToHeader.NAME)).setTag(((ToHeader) request
                .getHeader(ToHeader.NAME)).getTag());

        Address address = protocolObjects.addressFactory.createAddress("Shootme <sip:"
                + myAddress + ":" + myPort + ">");
        ContactHeader contactHeader = protocolObjects.headerFactory
                .createContactHeader(address);
        response.addHeader(contactHeader);
        st.sendResponse(response);
        assertEquals("Dialog state must be in confirmed state ",DialogState.CONFIRMED,dialog.getState());
        ReInviteInfoAckOverlapTest.assertEquals("Dialog for reinvite must match original dialog",
                dialog, this.dialog);

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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SwitchLabelElement类代码示例发布时间:2022-05-22
下一篇:
Java ContextAccessController类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap