本文整理汇总了Java中javax.sip.header.ExpiresHeader类的典型用法代码示例。如果您正苦于以下问题:Java ExpiresHeader类的具体用法?Java ExpiresHeader怎么用?Java ExpiresHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ExpiresHeader类属于javax.sip.header包,在下文中一共展示了ExpiresHeader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: makeRequest
import javax.sip.header.ExpiresHeader; //导入依赖的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;
}
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:30,代码来源:RegisterMessage.java
示例2: processNotify
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
public void processNotify(Request request,
ServerTransaction serverTransactionId) {
try {
System.out.println("subsciber: got a notify .");
if (serverTransactionId == null) {
System.out.println("subsciber: null TID.");
return;
}
Dialog dialog = serverTransactionId.getDialog();
System.out.println("Dialog State = " + dialog.getState());
Response response = messageFactory.createResponse(200, request);
serverTransactionId.sendResponse(response);
System.out.println("subsciber: Sending OK.");
System.out.println("Dialog State = " + dialog.getState());
// Unsubscribe to the Subscription. Note that if you do not unsubscribe the dialog will
// live on and eventually you will run out of memory.
Request unsub = dialog.createRequest(Request.SUBSCRIBE);
ExpiresHeader expiresHeader = headerFactory
.createExpiresHeader(0);
unsub.addHeader(expiresHeader);
EventHeader eventHeader = null;
eventHeader = headerFactory.createEventHeader("reg");
unsub.addHeader(eventHeader);
ClientTransaction ct = sipProvider.getNewClientTransaction(unsub);
ct.sendRequest();
dialog.delete();
} catch (Exception ex) {
ex.printStackTrace();
System.exit(0);
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:39,代码来源:Subscriber.java
示例3: makeRequest
import javax.sip.header.ExpiresHeader; //导入依赖的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;
}
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:34,代码来源:RegisterMessage.java
示例4: createAckRequest
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
/**
* Creates a default ACK SIPRequest message for this original request. Note that the
* defaultACK SIPRequest does not include the content of the original SIPRequest. If
* responseToHeader is null then the toHeader of this request is used to construct the ACK.
* Note that tag fields are just copied from the original SIP Request. Added by Jeff Keyser.
*
* @param responseToHeader To header to use for this request.
*
* @return A SIPRequest with an ACK method.
*/
public SIPRequest createAckRequest(To responseToHeader) {
// SIPRequest newRequest;
// Iterator headerIterator;
// SIPHeader nextHeader;
// cloning instead of iterating through headers so that lazy parsers don't have to parse the messages fully
// to create ACK requests
SIPRequest newRequest = (SIPRequest) this.clone();
// newRequest = new SIPRequest();
// newRequest.setRequestLine((RequestLine) this.requestLine.clone());
newRequest.setMethod(Request.ACK);
// Ack and cancel do not get ROUTE headers.
// Route header for ACK is assigned by the
// Dialog if necessary.
newRequest.removeHeader(RouteHeader.NAME);
// Remove proxy auth header.
// Assigned by the Dialog if necessary.
newRequest.removeHeader(ProxyAuthorizationHeader.NAME);
// Adding content is responsibility of user.
newRequest.removeContent();
// Content type header is removed since
// content length is 0.
newRequest.removeHeader(ContentTypeHeader.NAME);
// The CSeq header field in the
// ACK MUST contain the same value for the
// sequence number as was present in the
// original request, but the method parameter
// MUST be equal to "ACK".
try{
newRequest.getCSeq().setMethod(Request.ACK);
} catch (ParseException e) {
}
if (responseToHeader != null) {
newRequest.setTo(responseToHeader);
}
// CONTACT header does not apply for ACK requests.
newRequest.removeHeader(ContactHeader.NAME);
newRequest.removeHeader(ExpiresHeader.NAME);
ViaList via = newRequest.getViaHeaders();
// Bug reported by Gianluca Martinello
// The ACK MUST contain a single Via header field,
// and this MUST be equal to the top Via header
// field of the original
// request.
if(via != null && via.size() > 1) {
for(int i = 2; i < via.size(); i++) {
via.remove(i);
}
}
if (MessageFactoryImpl.getDefaultUserAgentHeader() != null) {
newRequest.setHeader(MessageFactoryImpl.getDefaultUserAgentHeader());
}
return newRequest;
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:67,代码来源:SIPRequest.java
示例5: createFactoriesAndHeaders
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void createFactoriesAndHeaders(Map<String, Object> parameters, SipComponent component) throws Exception {
headerFactory = sipFactory.createHeaderFactory();
addressFactory = sipFactory.createAddressFactory();
setMessageFactory(sipFactory.createMessageFactory());
fromHeader = component.resolveAndRemoveReferenceParameter(parameters, "fromHeader", FromHeader.class, null);
if (fromHeader == null) {
createFromHeader();
}
if (!presenceAgent) {
toHeader = component.resolveAndRemoveReferenceParameter(parameters, "toHeader", ToHeader.class, null);
if (toHeader == null) {
createToHeader();
}
}
viaHeaders = component.resolveAndRemoveReferenceParameter(parameters, "viaHeaders", List.class, null);
if (viaHeaders == null) {
createViaHeaders();
}
contentTypeHeader = component.resolveAndRemoveReferenceParameter(parameters, "contentTypeHeader", ContentTypeHeader.class, null);
if (contentTypeHeader == null) {
createContentTypeHeader();
}
callIdHeader = component.resolveAndRemoveReferenceParameter(parameters, "callIdHeader", CallIdHeader.class, null);
maxForwardsHeader = component.resolveAndRemoveReferenceParameter(parameters, "maxForwardsHeader", MaxForwardsHeader.class, null);
if (maxForwardsHeader == null) {
createMaxForwardsHeader();
}
// Optional Headers
eventHeader = component.resolveAndRemoveReferenceParameter(parameters, "eventHeader", EventHeader.class, null);
if (eventHeader == null) {
createEventHeader();
}
contactHeader = component.resolveAndRemoveReferenceParameter(parameters, "contactHeader", ContactHeader.class, null);
if (contactHeader == null) {
createContactHeader();
}
expiresHeader = component.resolveAndRemoveReferenceParameter(parameters, "expiresHeader", ExpiresHeader.class, null);
if (expiresHeader == null) {
createExpiresHeader();
}
extensionHeader = component.resolveAndRemoveReferenceParameter(parameters, "extensionHeader", ExtensionHeader.class, null);
}
开发者ID:HydAu,项目名称:Camel,代码行数:48,代码来源:SipConfiguration.java
示例6: getExpiresHeader
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
public ExpiresHeader getExpiresHeader() {
return expiresHeader;
}
开发者ID:HydAu,项目名称:Camel,代码行数:4,代码来源:SipConfiguration.java
示例7: setExpiresHeader
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
/**
* A custom Header object containing message expiration details. Must implement the type javax.sip.header.ExpiresHeader
*/
public void setExpiresHeader(ExpiresHeader expiresHeader) {
this.expiresHeader = expiresHeader;
}
开发者ID:HydAu,项目名称:Camel,代码行数:7,代码来源:SipConfiguration.java
示例8: getExpiresRegistration
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
public ExpiresHeader getExpiresRegistration() {
return expiresRegistration;
}
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:4,代码来源:SipManager.java
示例9: setExpiresRegistration
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
public void setExpiresRegistration(ExpiresHeader expiresRegistration) {
this.expiresRegistration = expiresRegistration;
}
开发者ID:SyMPHOnY-,项目名称:Smart-Home-Gateway,代码行数:4,代码来源:SipManager.java
示例10: sendResponse
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
public ServerTransaction sendResponse(int status, Request request, ServerTransaction serverTransaction) {
try {
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Starting response sending process.");
if (serverTransaction == null)
serverTransaction = udpSipProvider.getNewServerTransaction(request);
Response response = messageFactory.createResponse(status, request);
// Set "Exprires" header
if (request.getHeader(ExpiresHeader.NAME) != null)
response.setHeader(request.getHeader(ExpiresHeader.NAME));
// Add "Contact" header
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Preparing \"Contact\" header...");
try {
SipURI contactURI = addressFactory.createSipURI(null, InetAddress.getLocalHost().getHostAddress());
contactURI.setPort(sipPort);
Address contactAddress = addressFactory.createAddress(contactURI);
// contactAddress.setDisplayName(mySipUsername);
ContactHeader contactHeader = headerFactory.createContactHeader(contactAddress);
response.addHeader(contactHeader);
}
catch (Exception e) {
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Exception occured when adding ContactHeader.", e);
// return false; // We can continue with this though.
}
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Sending response: " + response.toString());
serverTransaction.sendResponse(response);
// udpSipProvider.sendResponse(response);
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Response sent!");
return serverTransaction;
}
catch (Exception ex) {
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: ", ex);
}
return null;
}
开发者ID:igniterealtime,项目名称:Openfire,代码行数:47,代码来源:SimpleSession.java
示例11: sendResponse
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
public ServerTransaction sendResponse(int status, Request request, ServerTransaction serverTransaction) {
try {
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Starting response sending process.");
if (serverTransaction == null)
serverTransaction = udpSipProvider.getNewServerTransaction(request);
Response response = messageFactory.createResponse(status, request);
// Set "Exprires" header
if (request.getHeader(ExpiresHeader.NAME) != null)
response.setHeader(request.getHeader(ExpiresHeader.NAME));
// Add "Contact" header
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Preparing \"Contact\" header...");
try {
SipURI contactURI = addressFactory.createSipURI(null, InetAddress.getLocalHost().getHostAddress());
contactURI.setPort(sipPort);
Address contactAddress = addressFactory.createAddress(contactURI);
// contactAddress.setDisplayName(mySipUsername);
ContactHeader contactHeader = headerFactory.createContactHeader(contactAddress);
response.addHeader(contactHeader);
}
catch (Exception e) {
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Exception occured when adding ContactHeader.", e);
// return false; // We can continue with this though.
}
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Sending response: " + response.toString());
serverTransaction.sendResponse(response);
// udpSipProvider.sendResponse(response);
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: Response sent!");
return serverTransaction;
}
catch (Exception ex) {
Log.debug("SimpleSession(" + jid.getNode() + ").sendResponse: ", ex);
}
return null;
}
开发者ID:coodeer,项目名称:g3server,代码行数:47,代码来源:SimpleSession.java
示例12: SipSubscription
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
SipSubscription(Request req)
{
CallIdHeader ch = (CallIdHeader) req.getHeader("Call-ID");
ToHeader th = (ToHeader) req.getHeader("To");
FromHeader fh = (FromHeader) req.getHeader("From");
rl = new LinkedList<Address>();
this.callId = ch.getCallId();
// incoming request from=remote
ContactHeader cont = (ContactHeader) req.getHeader(ContactHeader.NAME);
if (cont != null)
{
this.contact = cont.getAddress().getURI().toString();
}
// This is a server dialog. The top most record route
// header is the one that is closest to us. We extract the
// route list in the same order as the addresses in the
// incoming request.
if (rl.isEmpty())
{
ListIterator<?> rrl = req.getHeaders(RecordRouteHeader.NAME);
while (rrl.hasNext())
{
RecordRouteHeader rrh = (RecordRouteHeader) rrl.next();
rl.add(rrh.getAddress());
}
}
remoteTag = fh.getTag();
remoteParty = fh.getAddress();
localTag = th.getTag();
localParty = th.getAddress();
if (localTag == null)
{
localTag = Integer.toString((int) (Math.random() * 100000));
}
ExpiresHeader eh = (ExpiresHeader) req.getHeader(ExpiresHeader.NAME);
this.expires = System.currentTimeMillis() + (eh.getExpires() * 1000);
cseq = 1;
}
开发者ID:idwanglu2010,项目名称:openfire,代码行数:48,代码来源:SipSubscription.java
示例13: processOK
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
void processOK(ClientTransaction clientTransatcion, Response response) {
isRegistered = true;
FromHeader fromHeader = ((FromHeader) response
.getHeader(FromHeader.NAME));
Address address = fromHeader.getAddress();
int expires = 0;
if (!isUnregistering) {
ContactHeader contactHeader = (ContactHeader) response
.getHeader(ContactHeader.NAME);
// TODO check if the registrar created the contact address
if (contactHeader != null) {
expires = contactHeader.getExpires();
} else {
ExpiresHeader expiresHeader = response.getExpires();
if (expiresHeader != null) {
expires = expiresHeader.getExpires();
}
}
}
// expires may be null
// fix by Luca Bincoletto <[email protected]>
if (expires == 0) {
isUnregistering = false;
sipManCallback.fireUnregistered(address.toString());
} else {
if (reRegisterTimer != null)
reRegisterTimer.cancel();
if (keepAliveTimer != null)
keepAliveTimer.cancel();
reRegisterTimer = new Timer();
keepAliveTimer = new Timer();
// if (expires > 0 && expires < 60) {
// [issue 2] Schedule re registrations
// bug reported by [email protected]
// use the value returned by the server to reschedule
// registration
SipURI uri = (SipURI) address.getURI();
scheduleReRegistration(uri.getHost(), uri.getPort(), uri
.getTransportParam(), expires);
scheduleKeepAlive(SIPConfig.getKeepAliveDelay());
// }
/*
* else{ SipURI uri = (SipURI) address.getURI();
* scheduleReRegistration(uri.getHost(), uri.getPort(),
* uri.getTransportParam(), expires); }
*/
sipManCallback.fireRegistered(address.toString());
}
}
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:53,代码来源:RegisterProcessing.java
示例14: getExpires
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
/**
* Get the exipres header.
*
* @return the expires header or null if one does not exist.
*/
public javax.sip.header.ExpiresHeader getExpires() {
return (ExpiresHeader) getHeaderLowerCase(EXPIRES_LOWERCASE);
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:9,代码来源:SIPMessage.java
示例15: setExpires
import javax.sip.header.ExpiresHeader; //导入依赖的package包/类
/**
* Set the expiresHeader
*
* @param expiresHeader -- the expires header to set.
*/
public void setExpires(ExpiresHeader expiresHeader) {
this.setHeader(expiresHeader);
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:10,代码来源:SIPMessage.java
注:本文中的javax.sip.header.ExpiresHeader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论