本文整理汇总了Java中javax.sip.address.SipURI.setPort方法的典型用法代码示例。如果您正苦于以下问题:Java SipURI.setPort方法的具体用法?Java SipURI.setPort怎么用?Java SipURI.setPort使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sip.address.SipURI
的用法示例。
在下文中一共展示了SipURI.setPort方法的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;
}
}
示例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();
}
示例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();
}
示例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;
}
}
示例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());
}
}
示例6: rewriteUri
import javax.sip.address.SipURI; //导入方法依赖的package包/类
public void rewriteUri(SipURI uri) {
try {
String uriHost = uri.getHost();
if(uriHost.endsWith(".invalid")) {
uri.setHost(getPeerAddress());
}
} catch (ParseException e) {
logger.logError("Cant parse address", e);
}
uri.setPort(getPeerPort());
}
示例7: createFromHeader
import javax.sip.address.SipURI; //导入方法依赖的package包/类
private void createFromHeader() throws ParseException {
SipURI fromAddress = getAddressFactory().createSipURI(getFromUser(), getFromHost());
fromAddress.setPort(Integer.valueOf(getFromPort()).intValue());
Address fromNameAddress = addressFactory.createAddress(fromAddress);
fromNameAddress.setDisplayName(getFromUser());
setFromHeader(headerFactory.createFromHeader(fromNameAddress, getFromUser() + "_Header"));
}
示例8: createToHeader
import javax.sip.address.SipURI; //导入方法依赖的package包/类
private void createToHeader() throws ParseException {
SipURI toAddress = getAddressFactory().createSipURI(getToUser(), getToHost());
toAddress.setPort(getToPort());
Address toNameAddress = addressFactory.createAddress(toAddress);
toNameAddress.setDisplayName(getToUser());
setToHeader(headerFactory.createToHeader(toNameAddress, getToUser() + "_Header"));
}
示例9: createContactHeader
import javax.sip.address.SipURI; //导入方法依赖的package包/类
private void createContactHeader() throws ParseException {
SipURI contactURI = addressFactory.createSipURI(getFromUser(), getFromHost());
contactURI.setTransportParam(getTransport());
contactURI.setPort(Integer.valueOf(getFromPort()).intValue());
Address contactAddress = addressFactory.createAddress(contactURI);
// Add the contact address.
contactAddress.setDisplayName(getFromUser());
contactHeader = headerFactory.createContactHeader(contactAddress);
}
示例10: MakeRequest
import javax.sip.address.SipURI; //导入方法依赖的package包/类
/**
*
* @param sipManager - SipManager object
* @param to - To identifies receiver IP
* @param message Message that should be send
* @return Return SIP Message.
* @throws ParseException
* @throws InvalidArgumentException
*/
public Request MakeRequest(SipManager sipManager, String to, String message) throws ParseException, InvalidArgumentException {
AddressFactory addressFactory = sipManager.addressFactory;
sipManager.setCseqNumber((long)sipManager.getCseqNumber()+1l);
Address fromNameAddress = addressFactory.createAddress("sip:"+ SipManager.sipUserName + "@"+ SipManager.registrarIp);
FromHeader fromHeader = sipManager.headerFactory.createFromHeader(fromNameAddress, "SyMPHOnY");
URI toAddress = sipManager.addressFactory.createURI(to);
Address toNameAddress = sipManager.addressFactory.createAddress(toAddress);
ToHeader toHeader = sipManager.headerFactory.createToHeader(toNameAddress, null);
URI requestURI = sipManager.addressFactory.createURI(to);
ArrayList<ViaHeader> viaHeaders = sipManager.createViaHeader();
CallIdHeader callIdHeader = sipManager.sipProvider.getNewCallId();
CSeqHeader cSeqHeader = sipManager.headerFactory.createCSeqHeader(sipManager.getCseqNumber(),Request.MESSAGE);
MaxForwardsHeader maxForwards = sipManager.headerFactory
.createMaxForwardsHeader(70);
Request request = sipManager.messageFactory.createRequest(requestURI,
Request.MESSAGE, callIdHeader, cSeqHeader, fromHeader,
toHeader, viaHeaders, maxForwards);
SupportedHeader supportedHeader = sipManager.headerFactory
.createSupportedHeader("replaces, outbound");
request.addHeader(supportedHeader);
SipURI routeUri = sipManager.addressFactory.createSipURI(null,
SipManager.proxyIp);
routeUri.setTransportParam(SipManager.transport);
routeUri.setLrParam();
routeUri.setPort(SipManager.proxyPort);
Address routeAddress = sipManager.addressFactory
.createAddress(routeUri);
RouteHeader route = sipManager.headerFactory
.createRouteHeader(routeAddress);
request.addHeader(route);
ContentTypeHeader contentTypeHeader = sipManager.headerFactory
.createContentTypeHeader("text", "plain");
request.setContent(message, contentTypeHeader);
System.out.println(request);
return request;
}
示例11: getFromHeader
import javax.sip.address.SipURI; //导入方法依赖的package包/类
public FromHeader getFromHeader(boolean isNew)
throws CommunicationsException {
if (fromHeader != null && !isNew) {
return fromHeader;
}
try {
SipURI fromURI = (SipURI) addressFactory
.createURI(currentlyUsedURI);
fromURI.setTransportParam(listeningPoint.getTransport());
fromURI.setPort(listeningPoint.getPort());
Address fromAddress = addressFactory.createAddress(fromURI);
if (displayName != null && displayName.trim().length() > 0) {
fromAddress.setDisplayName(displayName);
} else {
fromAddress
.setDisplayName(UserCredentials.getUserDisplay());// UserCredentials.getUser());
// JOptionPane.showMessageDialog(null,currentlyUsedURI);
}
fromHeader = headerFactory.createFromHeader(fromAddress,
Integer.toString(hashCode()));
}
catch (ParseException ex) {
throw new CommunicationsException(
"A ParseException occurred while creating From Header!",
ex);
}
return fromHeader;
}
示例12: getFromHeader
import javax.sip.address.SipURI; //导入方法依赖的package包/类
public FromHeader getFromHeader(boolean isNew)
throws CommunicationsException {
if (fromHeader != null && !isNew) {
return fromHeader;
}
try {
SipURI fromURI = (SipURI) addressFactory
.createURI(currentlyUsedURI);
fromURI.setTransportParam(listeningPoint.getTransport());
fromURI.setPort(listeningPoint.getPort());
Address fromAddress = addressFactory.createAddress(fromURI);
if (displayName != null && displayName.trim().length() > 0) {
fromAddress.setDisplayName(displayName);
} else {
fromAddress
.setDisplayName(Credentials.getUserDisplay());
}
fromHeader = headerFactory.createFromHeader(fromAddress,
Integer.toString(hashCode()));
}
catch (ParseException ex) {
throw new CommunicationsException(
"A ParseException occurred while creating From Header!",
ex);
}
return fromHeader;
}
示例13: init
import javax.sip.address.SipURI; //导入方法依赖的package包/类
public void init() {
SipFactory sipFactory = null;
sipFactory = SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
Properties properties = new Properties();
/* remote peer host */
String peerHostPort = Shootist.peerHostPort;
String localHost = myAddress;
try {
headerFactory = protocolObjects.headerFactory;
addressFactory = protocolObjects.addressFactory;
messageFactory = protocolObjects.messageFactory;
String fromName = "BigGuy";
String fromSipAddress = "here.com";
String fromDisplayName = "The Master Blaster";
String toSipAddress = "there.com";
String toUser = "LittleGuy";
String toDisplayName = "The Little Blister";
// create >From Header
SipURI fromAddress = addressFactory.createSipURI(fromName,
fromSipAddress);
fromNameAddress = addressFactory.createAddress(fromAddress);
fromNameAddress.setDisplayName(fromDisplayName);
// create To Header
SipURI toAddress = addressFactory
.createSipURI(toUser, toSipAddress);
Address toNameAddress = addressFactory.createAddress(toAddress);
toNameAddress.setDisplayName(toDisplayName);
toHeader = headerFactory.createToHeader(toNameAddress, null);
// create Request URI
requestURI = addressFactory.createSipURI(toUser, peerHostPort);
// Create ContentTypeHeader
contentTypeHeader = headerFactory.createContentTypeHeader(
"application", "sdp");
// Create a new MaxForwardsHeader
maxForwards = headerFactory.createMaxForwardsHeader(70);
// Create contact headers
String host = localHost;
SipURI contactUrl = addressFactory.createSipURI(fromName, host);
contactUrl.setPort(listeningPoint.getPort());
// Create the contact name address.
SipURI contactURI = addressFactory.createSipURI(fromName, host);
contactURI.setPort(listeningPoint.getPort());
Address contactAddress = addressFactory.createAddress(contactURI);
// Add the contact address.
contactAddress.setDisplayName(fromName);
contactHeader = headerFactory.createContactHeader(contactAddress);
} catch (Exception ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
TxTimeoutTest.fail("Shootist: Error on init!", ex);
}
}
示例14: init
import javax.sip.address.SipURI; //导入方法依赖的package包/类
public void init() {
SipFactory sipFactory = null;
sipFactory = SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
Properties properties = new Properties();
/* remote peer host */
String peerHostPort = Shootist.peerHostPort;
String localHost = myAddress;
try {
headerFactory = protocolObjects.headerFactory;
addressFactory = protocolObjects.addressFactory;
messageFactory = protocolObjects.messageFactory;
String fromName = "BigGuy";
String fromSipAddress = "here.com";
String fromDisplayName = "The Master Blaster";
String toSipAddress = "there.com";
String toUser = "LittleGuy";
String toDisplayName = "The Little Blister";
// create >From Header
SipURI fromAddress = addressFactory.createSipURI(fromName,
fromSipAddress);
fromNameAddress = addressFactory.createAddress(fromAddress);
fromNameAddress.setDisplayName(fromDisplayName);
// create To Header
SipURI toAddress = addressFactory
.createSipURI(toUser, toSipAddress);
Address toNameAddress = addressFactory.createAddress(toAddress);
toNameAddress.setDisplayName(toDisplayName);
toHeader = headerFactory.createToHeader(toNameAddress, null);
// create Request URI
requestURI = addressFactory.createSipURI(toUser, peerHostPort);
// Create ContentTypeHeader
contentTypeHeader = headerFactory.createContentTypeHeader(
"application", "sdp");
// Create a new MaxForwardsHeader
maxForwards = headerFactory.createMaxForwardsHeader(70);
// Create contact headers
String host = localHost;
SipURI contactUrl = addressFactory.createSipURI(fromName, host);
contactUrl.setPort(listeningPoint.getPort());
// Create the contact name address.
SipURI contactURI = addressFactory.createSipURI(fromName, host);
contactURI.setPort(listeningPoint.getPort());
Address contactAddress = addressFactory.createAddress(contactURI);
// Add the contact address.
contactAddress.setDisplayName(fromName);
contactHeader = headerFactory.createContactHeader(contactAddress);
} catch (Exception ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
DialogTimeoutTest.fail("Shootist: Error on init!", ex);
}
}
示例15: init
import javax.sip.address.SipURI; //导入方法依赖的package包/类
public void init() {
SipFactory sipFactory = null;
sipFactory = SipFactory.getInstance();
sipFactory.setPathName("gov.nist");
Properties properties = new Properties();
/* remote peer host */
String peerHostPort = ShootistNotImplementingSipListenerExt.peerHostPort;
String localHost = myAddress;
try {
headerFactory = protocolObjects.headerFactory;
addressFactory = protocolObjects.addressFactory;
messageFactory = protocolObjects.messageFactory;
String fromName = "BigGuy";
String fromSipAddress = "here.com";
String fromDisplayName = "The Master Blaster";
String toSipAddress = "there.com";
String toUser = "LittleGuy";
String toDisplayName = "The Little Blister";
// create >From Header
SipURI fromAddress = addressFactory.createSipURI(fromName,
fromSipAddress);
fromNameAddress = addressFactory.createAddress(fromAddress);
fromNameAddress.setDisplayName(fromDisplayName);
// create To Header
SipURI toAddress = addressFactory
.createSipURI(toUser, toSipAddress);
Address toNameAddress = addressFactory.createAddress(toAddress);
toNameAddress.setDisplayName(toDisplayName);
toHeader = headerFactory.createToHeader(toNameAddress, null);
// create Request URI
requestURI = addressFactory.createSipURI(toUser, peerHostPort);
// Create ContentTypeHeader
contentTypeHeader = headerFactory.createContentTypeHeader(
"application", "sdp");
// Create a new MaxForwardsHeader
maxForwards = headerFactory.createMaxForwardsHeader(70);
// Create contact headers
String host = localHost;
SipURI contactUrl = addressFactory.createSipURI(fromName, host);
contactUrl.setPort(listeningPoint.getPort());
// Create the contact name address.
SipURI contactURI = addressFactory.createSipURI(fromName, host);
contactURI.setPort(listeningPoint.getPort());
Address contactAddress = addressFactory.createAddress(contactURI);
// Add the contact address.
contactAddress.setDisplayName(fromName);
contactHeader = headerFactory.createContactHeader(contactAddress);
} catch (Exception ex) {
System.out.println(ex.getMessage());
ex.printStackTrace();
DialogTimeoutTest.fail("Shootist: Error on init!", ex);
}
}