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


Java SipURI类代码示例

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


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

示例1: createContactHeader

import javax.sip.address.SipURI; //导入依赖的package包/类
public ContactHeader createContactHeader() {
    try {
        String ipAddress = this.getIPAddress();
        int port = this.getPort();
        SipURI sipURI = new SipUri();
        sipURI.setHost(ipAddress);
        sipURI.setPort(port);
        sipURI.setTransportParam(this.transport);
        Contact contact = new Contact();
        AddressImpl address = new AddressImpl();
        address.setURI(sipURI);
        contact.setAddress(address);
        
        return contact;
    } catch (Exception ex) {
        InternalErrorHandler.handleException("Unexpected exception",logger);
        return null;
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:20,代码来源:ListeningPointImpl.java

示例2: sendTo

import javax.sip.address.SipURI; //导入依赖的package包/类
private void sendTo(ServerTransaction st, Request request, int targetPort) throws Exception {
    Request newRequest = (Request) request.clone();
    
    SipURI sipUri = addressFactory.createSipURI("UA1", "127.0.0.1");
    sipUri.setPort(targetPort);
    sipUri.setLrParam();
    sipUri.setTransportParam(Shootme.transport);
    Address address = addressFactory.createAddress("client1", sipUri);
    RouteHeader rheader = headerFactory.createRouteHeader(address);

    newRequest.addFirst(rheader);
    ViaHeader viaHeader = headerFactory.createViaHeader(host, this.port, "udp", null);
    newRequest.addFirst(viaHeader);
    ClientTransaction ct1 = sipProviders.get(Shootme.transport).getNewClientTransaction(newRequest);
    sipUri = addressFactory.createSipURI("proxy", "127.0.0.1");
    address = addressFactory.createAddress("proxy", sipUri);
    sipUri.setPort(5070);
    sipUri.setLrParam();
    RecordRouteHeader recordRoute = headerFactory.createRecordRouteHeader(address);
    newRequest.addHeader(recordRoute);
    ct1.setApplicationData(st);
    ct1.sendRequest();
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:24,代码来源:Proxy.java

示例3: sendTo

import javax.sip.address.SipURI; //导入依赖的package包/类
private void sendTo(ServerTransaction st, Request request, int targetPort) throws Exception {
    Request newRequest = (Request) request.clone();
    
    SipURI sipUri = addressFactory.createSipURI("UA1", "127.0.0.1");
    sipUri.setPort(targetPort);
    sipUri.setLrParam();
    Address address = addressFactory.createAddress("client1", sipUri);
    RouteHeader rheader = headerFactory.createRouteHeader(address);

    newRequest.addFirst(rheader);
    ViaHeader viaHeader = headerFactory.createViaHeader(host, this.port, transport, null);
    newRequest.addFirst(viaHeader);
    ClientTransaction ct1 = sipProvider.getNewClientTransaction(newRequest);
    sipUri = addressFactory.createSipURI("proxy", "127.0.0.1");
    address = addressFactory.createAddress("proxy", sipUri);
    sipUri.setPort(5070);
    sipUri.setLrParam();
    RecordRouteHeader recordRoute = headerFactory.createRecordRouteHeader(address);
    newRequest.addHeader(recordRoute);
    ct1.setApplicationData(st);
    this.clientTxTable.put(new Integer(targetPort), ct1);
    ct1.sendRequest();
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:24,代码来源:Proxy.java

示例4: createTiContact

import javax.sip.address.SipURI; //导入依赖的package包/类
/**
 * Add a contact for the TI.
 */
public ContactHeader createTiContact() throws Exception {
    try {
        ContactHeader contact = tiHeaderFactory.createContactHeader();

        // JvB: getIPAddress may return null!
        String ip = tiSipProvider.getSipStack().getIPAddress();
        if (ip == null) {
            ListeningPoint lp = (ListeningPoint) tiSipProvider
                    .getSipStack().getListeningPoints().next();
            ip = lp.getIPAddress();
        }

        SipURI srcSipURI = tiAddressFactory.createSipURI(null, ip);
        srcSipURI.setPort(tiSipProvider.getListeningPoint("udp").getPort());
        srcSipURI.setTransportParam("udp");
        Address address = tiAddressFactory.createAddress(srcSipURI);
        address.setDisplayName("TI Contact");
        contact.setAddress(address);
        return contact;
    } catch (Exception ex) {
        ex.printStackTrace();
        assertTrue(false);
        throw ex;
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:29,代码来源:MessageFlowHarness.java

示例5: createRiContact

import javax.sip.address.SipURI; //导入依赖的package包/类
/**
 * Add a contact for the TI.
 */
public ContactHeader createRiContact() throws TckInternalError {
    try {
        ContactHeader contact = riHeaderFactory.createContactHeader();
        // BUG reported by Ben Evans (Open Cloud):
        // Should be using RI's address factory here, not TI's.

        ListeningPoint lp = riSipProvider.getListeningPoints()[0];
        SipURI srcSipURI = riAddressFactory.createSipURI(null, lp
                .getIPAddress());
        srcSipURI.setPort(lp.getPort());
        srcSipURI.setTransportParam(lp.getTransport());
        Address address = riAddressFactory.createAddress(srcSipURI);
        address.setDisplayName("RI Contact");
        contact.setAddress(address);
        return contact;
    } catch (Exception ex) {
        throw new TckInternalError(ex.getMessage());
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:23,代码来源:MessageFlowHarness.java

示例6: testHeaderParams

import javax.sip.address.SipURI; //导入依赖的package包/类
/**
 * This tests that header parameters are properly assigned to the header, not the URI,
 * when there are no angle brackets
 */
public void testHeaderParams() {
    try {
        Header h = tiHeaderFactory.createHeader( "m", "sip:[email protected]:1234;param1" );
        System.err.println( h );
        assertTrue( h instanceof ContactHeader );
        ContactHeader c = (ContactHeader) h;
        URI u = c.getAddress().getURI();
        assertTrue( u.isSipURI() );
        assertNull( "URI must have no params", ((SipURI)u).getParameter("param1") );
        assertNotNull( "Parameter 'param1' must be assigned to the header", c.getParameter("param1") );
    } catch (ParseException e) {
        e.printStackTrace();
        fail( e.getMessage() );
    } finally {
        logTestCompleted("testHeaderParams()");
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:HeaderFactoryTest.java

示例7: testHeaderParams2

import javax.sip.address.SipURI; //导入依赖的package包/类
/**
 * This tests that header parameters are properly assigned to the header, not the URI,
 * when there are no angle brackets - in particular for 'tag'
 */
public void testHeaderParams2() {
    try {
        Header h = tiHeaderFactory.createHeader( "From", "sip:[email protected];tag=gc2zbu" );
        System.err.println( h );
        assertTrue( h instanceof FromHeader );
        FromHeader c = (FromHeader) h;
        URI u = c.getAddress().getURI();
        assertTrue( u.isSipURI() );
        assertFalse( "URI must have no params", ((SipURI)u).getParameterNames().hasNext() );
        assertNotNull( "Parameter 'tag' must be assigned to the header", c.getTag() );
    } catch (ParseException e) {
        e.printStackTrace();
        fail( e.getMessage() );
    } finally {
        logTestCompleted("testHeaderParams2()");
    }
}
 
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:22,代码来源:HeaderFactoryTest.java

示例8: prepareMessageRequest

import javax.sip.address.SipURI; //导入依赖的package包/类
private Request prepareMessageRequest(MessageContent content, String destination) throws InvalidArgumentException, ParseException {
    String destUsername = destination;
    String destHost     = sipHost;
    
    if (destination.indexOf("@") == 0 || destination.indexOf("@") == destination.length() - 1) {
        throw new InvalidArgumentException("The address provided is invalid!");
    }
    else if (destination.indexOf("@") > 0) {
        destUsername = destination.substring(0, destination.indexOf("@"));
        destHost     = destination.substring(destination.indexOf("@") + 1);
    }
    
    SipURI destUri = addressFactory.createSipURI(destUsername, destHost);
    
    Request messageRequest = prepareRequest(RequestType.MESSAGE, destUri, null, destUri, sessionId, seqNum++);
    
    messageRequest.setContent(content.content, content.contentTypeHeader);
    
    return messageRequest;
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:21,代码来源:SimpleSession.java

示例9: prepareSubscribeRequest

import javax.sip.address.SipURI; //导入依赖的package包/类
private Request prepareSubscribeRequest(String destination) throws InvalidArgumentException, ParseException {
    String destUsername = destination;
    String destHost     = sipHost;
    
    if (destination.indexOf("@") == 0 || destination.indexOf("@") == destination.length() - 1) {
        throw new InvalidArgumentException("The address provided is invalid!");
    }
    else if (destination.indexOf("@") > 0) {
        destUsername = destination.substring(0, destination.indexOf("@"));
        destHost     = destination.substring(destination.indexOf("@") + 1);
    }
    
    SipURI destUri = addressFactory.createSipURI(destUsername, destHost);
    
    return prepareRequest(RequestType.SUBSCRIBE, destUri, null, destUri, null, 1L);
}
 
开发者ID:igniterealtime,项目名称:Openfire,代码行数:17,代码来源:SimpleSession.java

示例10: prepareMessageRequest

import javax.sip.address.SipURI; //导入依赖的package包/类
private Request prepareMessageRequest(MessageContent content, String destination) throws InvalidArgumentException, ParseException {
	String destUsername = destination;
	String destHost     = sipHost;
	
	if (destination.indexOf("@") == 0 || destination.indexOf("@") == destination.length() - 1) {
		throw new InvalidArgumentException("The address provided is invalid!");
	}
	else if (destination.indexOf("@") > 0) {
		destUsername = destination.substring(0, destination.indexOf("@"));
		destHost     = destination.substring(destination.indexOf("@") + 1);
	}
	
	SipURI destUri = addressFactory.createSipURI(destUsername, destHost);
	
	Request messageRequest = prepareRequest(RequestType.MESSAGE, destUri, null, destUri, sessionId, seqNum++);
	
	messageRequest.setContent(content.content, content.contentTypeHeader);
	
	return messageRequest;
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:21,代码来源:SimpleSession.java

示例11: prepareSubscribeRequest

import javax.sip.address.SipURI; //导入依赖的package包/类
private Request prepareSubscribeRequest(String destination) throws InvalidArgumentException, ParseException {
	String destUsername = destination;
	String destHost     = sipHost;
	
	if (destination.indexOf("@") == 0 || destination.indexOf("@") == destination.length() - 1) {
		throw new InvalidArgumentException("The address provided is invalid!");
	}
	else if (destination.indexOf("@") > 0) {
		destUsername = destination.substring(0, destination.indexOf("@"));
		destHost     = destination.substring(destination.indexOf("@") + 1);
	}
	
	SipURI destUri = addressFactory.createSipURI(destUsername, destHost);
	
	return prepareRequest(RequestType.SUBSCRIBE, destUri, null, destUri, null, 1L);
}
 
开发者ID:coodeer,项目名称:g3server,代码行数:17,代码来源:SimpleSession.java

示例12: getSubscription

import javax.sip.address.SipURI; //导入依赖的package包/类
public static SipSubscription getSubscription(String user, String dest)
{
	synchronized (subscriptions)
	{
		List<SipSubscription> subs = subscriptions.get(user);

		if (subs!=null)
		{
			for (SipSubscription sub : subs)
			{
				String subDest = ((SipURI) sub.remoteParty.getURI()).getUser();

				if (subDest.equals(dest))
				{
					return sub;
				}
			}
		}
	}
	return null;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:22,代码来源:SipSubscriptionManager.java

示例13: getWatcher

import javax.sip.address.SipURI; //导入依赖的package包/类
public static SipSubscription getWatcher(String user, String dest)
{
	synchronized (watchers)
	{
		List<SipSubscription> subs = watchers.get(user);

		if (subs!=null)
		{
			for (SipSubscription sub : subs)
			{
				String subDest = ((SipURI) sub.remoteParty.getURI()).getUser();

				if (subDest.equals(dest))
				{
					return sub;
				}
			}
		}
	}
	return null;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:22,代码来源:SipSubscriptionManager.java

示例14: removeSubscription

import javax.sip.address.SipURI; //导入依赖的package包/类
public static SipSubscription removeSubscription(String user, String dest)
{
	synchronized (subscriptions)
	{
		List<SipSubscription> subs = subscriptions.get(user);

		if (subs!=null)
		{
			for (SipSubscription sub : subs)
			{
				String subDest = ((SipURI) sub.remoteParty.getURI()).getUser();

				if (subDest.equals(dest))
				{
					sub.cancel();
					subs.remove(sub);
					deleteSubscription(sub);
					return sub;
				}
			}
		}
	}
	return null;
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:25,代码来源:SipSubscriptionManager.java

示例15: saveSubscription

import javax.sip.address.SipURI; //导入依赖的package包/类
public static void saveSubscription(SipSubscription sub) throws IOException, SAXException
{
	String filename = spoolPath + "/subscriptions/" + ((SipURI) sub.localParty.getURI()).getUser() + "_" + sub.callId;
	FileOutputStream fs = new FileOutputStream(new File(filename));

	OutputFormat of = new OutputFormat("XML", "ISO-8859-1", true);
	of.setIndent(1);
	of.setIndenting(true);
	XMLSerializer serializer = new XMLSerializer(fs, of);
	ContentHandler hd = serializer.asContentHandler();
	hd.startDocument();
	hd.startElement("", "", "SUBSCRIPTION", null);
	sub.buildSubscriptionXML(hd);
	hd.endElement("", "", "SUBSCRIPTION");
	hd.endDocument();
	fs.close();
}
 
开发者ID:idwanglu2010,项目名称:openfire,代码行数:18,代码来源:SipSubscriptionManager.java


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