本文整理汇总了Java中javax.sip.address.SipURI.setTransportParam方法的典型用法代码示例。如果您正苦于以下问题:Java SipURI.setTransportParam方法的具体用法?Java SipURI.setTransportParam怎么用?Java SipURI.setTransportParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.sip.address.SipURI
的用法示例。
在下文中一共展示了SipURI.setTransportParam方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
}
示例4: 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());
}
}
示例5: 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);
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: sendInvite
import javax.sip.address.SipURI; //导入方法依赖的package包/类
public void sendInvite( ReferToHeader to ) {
try {
String fromName = "Referee";
String fromSipAddress = "here.com";
String fromDisplayName = "The Master Blaster";
// create >From Header
SipURI fromAddress = addressFactory.createSipURI(fromName,
fromSipAddress);
Address fromNameAddress = addressFactory.createAddress(fromAddress);
fromNameAddress.setDisplayName(fromDisplayName);
FromHeader fromHeader = headerFactory.createFromHeader(
fromNameAddress, "12345");
// create To Header
ToHeader toHeader = headerFactory.createToHeader( to.getAddress(),
null);
// get Request URI
SipURI requestURI = (SipURI) to.getAddress().getURI();
ListeningPoint lp = mySipProvider.getListeningPoint(transport);
// Create ViaHeaders
ArrayList viaHeaders = new ArrayList();
ViaHeader viaHeader = headerFactory.createViaHeader("127.0.0.1",
lp.getPort(), transport, null);
// add via headers
viaHeaders.add(viaHeader);
// Create a new CallId header
CallIdHeader callIdHeader = mySipProvider.getNewCallId();
// JvB: Make sure that the implementation matches the messagefactory
callIdHeader = headerFactory.createCallIdHeader( callIdHeader.getCallId() );
// Create a new Cseq header
CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(1L,
Request.INVITE);
// Create a new MaxForwardsHeader
MaxForwardsHeader maxForwards = headerFactory
.createMaxForwardsHeader(70);
// Create the request. (TODO should read request type from Refer-To)
Request request = messageFactory.createRequest(requestURI,
Request.INVITE, callIdHeader, cSeqHeader, fromHeader,
toHeader, viaHeaders, maxForwards);
// Create contact headers
String host = lp.getIPAddress();
SipURI contactURI = addressFactory.createSipURI(fromName, host);
contactURI.setPort(lp.getPort());
contactURI.setTransportParam( transport );
Address contactAddress = addressFactory.createAddress(contactURI);
// Add the contact address.
contactAddress.setDisplayName(fromName);
ContactHeader contactHeader = headerFactory.createContactHeader(contactAddress);
request.addHeader(contactHeader);
// Create the client transaction.
ClientTransaction inviteTid = mySipProvider.getNewClientTransaction(request);
logger.info("Invite Dialog = " + inviteTid.getDialog());
// send the request out.
inviteTid.sendRequest();
} catch (Throwable ex) {
TestHarness.fail("Failed to send INVITE, because of " + ex);
}
}
示例10: MakeRequest
import javax.sip.address.SipURI; //导入方法依赖的package包/类
/**
*
* @param sipManager - SipManager object
* @param to - identifies receiver IP
* @param message is message that should be send
* @return
* @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);
//SipURI from = sipManager.addressFactory.createSipURI(sipManager.getSipProfile().getSipUserName(), sipManager.getSipProfile().getLocalEndpoint());
//Address fromNameAddress = sipManager.addressFactory.createAddress(from);
Address fromNameAddress = addressFactory.createAddress("sip:"+ SipManager.sipUserName + "@"+ SipManager.registrarIp);
// fromNameAddress.setDisplayName(sipUsername);
FromHeader fromHeader = sipManager.headerFactory.createFromHeader(fromNameAddress, "SyMPHOnY");
URI toAddress = sipManager.addressFactory.createURI(to);
Address toNameAddress = sipManager.addressFactory.createAddress(toAddress);
// toNameAddress.setDisplayName(username);
ToHeader toHeader = sipManager.headerFactory.createToHeader(toNameAddress, null);
URI requestURI = sipManager.addressFactory.createURI(to);
// requestURI.setTransportParam("udp");
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: init
import javax.sip.address.SipURI; //导入方法依赖的package包/类
boolean init()
{
try {
SipURI from = addressFactory.createSipURI(getFromUsername(), getFromHost()
+ ":" + getFromPort());
Address fromNameAddress = addressFactory.createAddress(from);
fromNameAddress.setDisplayName(getFromUsername());
FromHeader fromHeader = headerFactory.createFromHeader(fromNameAddress,
getSoftwareVersion());
SipURI toAddress = addressFactory.createSipURI(getToUsername(), getToHost()
+ ":" + getToPort());
Address toNameAddress = addressFactory.createAddress(toAddress);
toNameAddress.setDisplayName(getToUsername());
ToHeader toHeader = headerFactory.createToHeader(toNameAddress, null);
SipURI requestURI = addressFactory.createSipURI(getToUsername(), getToHost()
+ ":" + getToPort());
requestURI.setTransportParam("udp");
ArrayList<ViaHeader> viaHeaders = new ArrayList<ViaHeader>();
ViaHeader viaHeader = headerFactory.createViaHeader(getFromHost(),
getFromPort(), "udp", null);
viaHeaders.add(viaHeader);
CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(1L, message);
MaxForwardsHeader maxForwards = headerFactory
.createMaxForwardsHeader(70);
request = messageFactory.createRequest(requestURI,
message, callIdHeader, cSeqHeader, fromHeader,
toHeader, viaHeaders, maxForwards);
SipURI contactURI = addressFactory.createSipURI(getFromUsername(),
getFromHost());
contactURI.setPort(getFromPort());
Address contactAddress = addressFactory.createAddress(contactURI);
contactAddress.setDisplayName(getFromUsername());
ContactHeader contactHeader = headerFactory
.createContactHeader(contactAddress);
request.addHeader(contactHeader);
}
catch (Exception e)
{
logger.error("Error initializing stack: ", e);
return false;
}
return true;
}