本文整理汇总了Java中gov.nist.javax.sip.address.SipUri类的典型用法代码示例。如果您正苦于以下问题:Java SipUri类的具体用法?Java SipUri怎么用?Java SipUri使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SipUri类属于gov.nist.javax.sip.address包,在下文中一共展示了SipUri类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createContactHeader
import gov.nist.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;
}
}
示例2: setDefaults
import gov.nist.javax.sip.address.SipUri; //导入依赖的package包/类
/**
* Set the default values in the request URI if necessary.
*/
protected void setDefaults() {
// The request line may be unparseable (set to null by the
// exception handler.
if (requestLine == null)
return;
String method = requestLine.getMethod();
// The requestLine may be malformed!
if (method == null)
return;
GenericURI u = requestLine.getUri();
if (u == null)
return;
if (method.compareTo(Request.REGISTER) == 0 || method.compareTo(Request.INVITE) == 0) {
if (u instanceof SipUri) {
SipUri sipUri = (SipUri) u;
sipUri.setUserParam(DEFAULT_USER);
try {
sipUri.setTransportParam(DEFAULT_TRANSPORT);
} catch (ParseException ex) {
}
}
}
}
示例3: createRequest
import gov.nist.javax.sip.address.SipUri; //导入依赖的package包/类
/**
* Generate a request from a response.
*
* @param requestURI
* -- the request URI to assign to the request.
* @param via
* -- the Via header to assign to the request
* @param cseq
* -- the CSeq header to assign to the request
* @param from
* -- the From header to assign to the request
* @param to
* -- the To header to assign to the request
* @return -- the newly generated sip request.
*/
public SIPRequest createRequest(SipUri requestURI, Via via, CSeq cseq,
From from, To to) {
SIPRequest newRequest = new SIPRequest();
String method = cseq.getMethod();
newRequest.setMethod(method);
newRequest.setRequestURI(requestURI);
this.setBranch(via, method);
newRequest.setHeader(via);
newRequest.setHeader(cseq);
newRequest.setHeader(from);
newRequest.setHeader(to);
newRequest.setHeader(getCallId());
try {
// JvB: all requests need a Max-Forwards
newRequest.attachHeader(new MaxForwards(70), false);
} catch (Exception d) {
}
if (MessageFactoryImpl.getDefaultUserAgentHeader() != null) {
newRequest
.setHeader(MessageFactoryImpl.getDefaultUserAgentHeader());
}
return newRequest;
}
示例4: testUserNullabilityInSipUri
import gov.nist.javax.sip.address.SipUri; //导入依赖的package包/类
public void testUserNullabilityInSipUri() throws ParseException {
// Given a URI with host set and null set as the user
SipUri uri = new SipUri();
uri.setUser(null);
uri.setHost("172.18.3.242");
// When
String userAtHost = uri.getUserAtHost();
String userAtHostPort = uri.getUserAtHostPort();
// Then
assertEquals("userAtHost equals host", userAtHost, "172.18.3.242");
assertEquals("userAtHostPort equals host", userAtHostPort, "172.18.3.242");
}
示例5: get
import gov.nist.javax.sip.address.SipUri; //导入依赖的package包/类
private static String get(HeaderAddress header, Function<SipUri, String> getter) {
URI uri = getURI(header);
if (uri instanceof SipUri) {
return getter.apply((SipUri) uri);
} else if (uri instanceof TelURL) {
return ((TelURL) uri).getPhoneNumber();
}
return null;
}
示例6: parseUser
import gov.nist.javax.sip.address.SipUri; //导入依赖的package包/类
public static String parseUser(HeaderAddress header) {
return get(header, SipUri::getUser);
}
示例7: parseUserAtHostPort
import gov.nist.javax.sip.address.SipUri; //导入依赖的package包/类
public static String parseUserAtHostPort(HeaderAddress header) {
return get(header, SipUri::getUserAtHostPort);
}
示例8: parseSIPUrl
import gov.nist.javax.sip.address.SipUri; //导入依赖的package包/类
/**
* Parse a SIP url from a string and return a URI structure for it.
*
* @param url
* a String containing the URI structure to be parsed.
* @return A parsed URI structure
* @exception ParseException
* if there was an error parsing the message.
*/
public SipUri parseSIPUrl(String url) throws ParseException {
try {
return new URLParser(url).sipURL(true);
} catch (ClassCastException ex) {
throw new ParseException(url + " Not a SIP URL ", 0);
}
}