本文整理汇总了Java中javax.sip.address.AddressFactory类的典型用法代码示例。如果您正苦于以下问题:Java AddressFactory类的具体用法?Java AddressFactory怎么用?Java AddressFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AddressFactory类属于javax.sip.address包,在下文中一共展示了AddressFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeRequest
import javax.sip.address.AddressFactory; //导入依赖的package包/类
public Request makeRequest(SipManager sipManager, long cseqNumber, int expiresTime) throws ParseException, InvalidArgumentException {
AddressFactory addressFactory = sipManager.addressFactory;
SipProvider sipProvider = sipManager.sipProvider;
MessageFactory messageFactory = sipManager.messageFactory;
HeaderFactory headerFactory = sipManager.headerFactory;
// Create addresses and via header for the request
Address fromAddress = addressFactory.createAddress("sip:"+ SipManager.sipUserName + "@"+ SipManager.registrarIp);
fromAddress.setDisplayName(SipManager.sipUserName);
Address toAddress = addressFactory.createAddress("sip:" + SipManager.sipUserName + "@" + SipManager.registrarIp);
toAddress.setDisplayName(SipManager.sipUserName);
Address contactAddress = sipManager.createContactAddress();
ArrayList<ViaHeader> viaHeaders = sipManager.createViaHeader();
URI requestURI = addressFactory.createAddress("sip:" + SipManager.registrarIp).getURI();
// Build the request
final Request request = messageFactory.createRequest(requestURI,
Request.REGISTER, sipProvider.getNewCallId(),
headerFactory.createCSeqHeader(cseqNumber, Request.REGISTER),
headerFactory.createFromHeader(fromAddress, "c3ff411e"),
headerFactory.createToHeader(toAddress, null), viaHeaders,
headerFactory.createMaxForwardsHeader(70));
// Add the contact header
request.addHeader(headerFactory.createContactHeader(contactAddress));
ExpiresHeader eh = headerFactory.createExpiresHeader(expiresTime);
request.addHeader(eh);
// Print the request
System.out.println(request.toString());
return request;
}
示例2: testParser
import javax.sip.address.AddressFactory; //导入依赖的package包/类
@Override
public void testParser() {
System.out.println("*****************************************************");
System.out.println("parsie parsie.....");
System.out.println("*****************************************************");
String[] p_serv_user = {"P-Served-User: <sip:[email protected]>;regstate=reg;sescase=orig\n",
"P-Served-User: <sip:[email protected]>;regstate=unreg\n",
"P-Served-User: <sip:[email protected]>;sescase=term\n",
"P-Served-User: <sip:[email protected]>\n",
"P-Served-User: <sip:[email protected];transport=UDP>;sescase=term;regstate=unreg\n"};
super.testParser(PServedUserParser.class, p_serv_user);
System.out.println("******************************************************");
System.out.println("From the perspective of the application, lets test the");
System.out.println("encoding and usage of the P-Served-User header.");
System.out.println("******************************************************");
HeaderFactoryImpl himpl = new HeaderFactoryImpl();
AddressFactory addfact = new AddressFactoryImpl();
try {
PServedUserHeader psuh = himpl.createPServedUserHeader(addfact.createAddress(addfact.createSipURI("aayush", "rancore.com")));
psuh.setSessionCase("orig");
psuh.setRegistrationState("reg");
System.out.println("The encoded header is---> "+psuh.toString());
System.out.println("The sescase is---> "+psuh.getSessionCase());
System.out.println("The Regs state is--->"+psuh.getRegistrationState());
} catch (ParseException e) {
assertTrue(false);
}
}
示例3: testParser
import javax.sip.address.AddressFactory; //导入依赖的package包/类
@Override
public void testParser() {
System.out.println("*****************************************************");
System.out.println("parsie parsie.....");
System.out.println("*****************************************************");
String p_prof_key[] = {"P-Profile-Key: <sip:[email protected]>\n",
"P-Profile-Key: <sip:chatroom-!.*[email protected]>\n",
"P-Profile-Key: <sip:[email protected]>\n"};
super.testParser(PProfileKeyParser.class, p_prof_key);
System.out.println("*****************************************************");
System.out.println("From the perspective of the application, let us test");
System.out.println("The creation of this header.....");
System.out.println("*****************************************************");
HeaderFactoryImpl himpl = new HeaderFactoryImpl();
AddressFactory addFactory = new AddressFactoryImpl();
try {
PProfileKeyHeader ppkey = himpl.createPProfileKeyHeader
(addFactory.createAddress("aayush's room",
addFactory.createSipURI("aayushzChatRoom-19", "rancoremumbai.com")));
System.out.println("The newly encoded header is---> "+ppkey.toString());
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例4: RequestFactory
import javax.sip.address.AddressFactory; //导入依赖的package包/类
@Inject
public RequestFactory(final MessageFactory messageFactory,
final HeaderFactory headerFactory,
final AddressFactory addressFactory) {
this.messageFactory = messageFactory;
this.headerFactory = headerFactory;
this.addressFactory = addressFactory;
}
示例5: MakeRequest
import javax.sip.address.AddressFactory; //导入依赖的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;
}
示例6: makeRequest
import javax.sip.address.AddressFactory; //导入依赖的package包/类
public Request makeRequest(SipManager sipManager, long cseqNumber, int expiresTime) throws ParseException, InvalidArgumentException {
AddressFactory addressFactory = sipManager.addressFactory;
SipProvider sipProvider = sipManager.sipProvider;
MessageFactory messageFactory = sipManager.messageFactory;
HeaderFactory headerFactory = sipManager.headerFactory;
// Create addresses and via header for the request
Address fromAddress = addressFactory.createAddress("sip:"+ SipManager.sipUserName + "@"+ SipManager.registrarIp);
fromAddress.setDisplayName(SipManager.sipUserName);
Address toAddress = addressFactory.createAddress("sip:" + SipManager.sipUserName + "@" + SipManager.registrarIp);
toAddress.setDisplayName(SipManager.sipUserName);
Address contactAddress = sipManager.createContactAddress();
ArrayList<ViaHeader> viaHeaders = sipManager.createViaHeader();
URI requestURI = addressFactory.createAddress("sip:" + SipManager.registrarIp).getURI();
// Build the request
final Request request = messageFactory.createRequest(requestURI,
Request.REGISTER, sipProvider.getNewCallId(),
headerFactory.createCSeqHeader(cseqNumber, Request.REGISTER),
headerFactory.createFromHeader(fromAddress, "c3ff411e"),
headerFactory.createToHeader(toAddress, null), viaHeaders,
headerFactory.createMaxForwardsHeader(70));
// Add the contact header
request.addHeader(headerFactory.createContactHeader(contactAddress));
ExpiresHeader eh = headerFactory.createExpiresHeader(expiresTime);
request.addHeader(eh);
// Print the request
System.out.println(request.toString());
return request;
}
示例7: getAddressFactory
import javax.sip.address.AddressFactory; //导入依赖的package包/类
public AddressFactory getAddressFactory() {
return addressFactory;
}
示例8: setAddressFactory
import javax.sip.address.AddressFactory; //导入依赖的package包/类
/**
* To use a custom AddressFactory
*/
public void setAddressFactory(AddressFactory addressFactory) {
this.addressFactory = addressFactory;
}
示例9: MakeRequest
import javax.sip.address.AddressFactory; //导入依赖的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;
}