本文整理汇总了Java中javax.sip.header.SubscriptionStateHeader类的典型用法代码示例。如果您正苦于以下问题:Java SubscriptionStateHeader类的具体用法?Java SubscriptionStateHeader怎么用?Java SubscriptionStateHeader使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
SubscriptionStateHeader类属于javax.sip.header包,在下文中一共展示了SubscriptionStateHeader类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: run
import javax.sip.header.SubscriptionStateHeader; //导入依赖的package包/类
public void run() {
try {
for (int i = 0; i < 1; i++) {
Thread.sleep(1000);
Request request = this.notifier.dialog.createRequest(Request.NOTIFY);
SubscriptionStateHeader subscriptionState = headerFactory
.createSubscriptionStateHeader(SubscriptionStateHeader.ACTIVE);
request.addHeader(subscriptionState);
request.addHeader(eventHeader);
// Lets mark our Contact
((SipURI)dialog.getLocalParty().getURI()).setParameter("id","not2");
ClientTransaction ct = sipProvider.getNewClientTransaction(request);
logger.info("NOTIFY Branch ID " +
((ViaHeader)request.getHeader(ViaHeader.NAME)).getParameter("branch"));
this.notifier.dialog.sendRequest(ct);
logger.info("Dialog " + dialog);
logger.info("Dialog state after active NOTIFY: " + dialog.getState());
}
} catch (Throwable ex) {
logger.info(ex.getMessage(), ex);
TestHarness.fail("Failed MyEventSource.run(), because of " + ex.getMessage());
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:29,代码来源:Notifier.java
示例2: processNotify
import javax.sip.header.SubscriptionStateHeader; //导入依赖的package包/类
public synchronized void processNotify(RequestEvent requestEvent,
ServerTransaction serverTransactionId) {
LOG.debug("Notification received at Subscriber");
SipProvider provider = (SipProvider) requestEvent.getSource();
Request notify = requestEvent.getRequest();
try {
if (serverTransactionId == null) {
LOG.info("ServerTransaction is null. Creating new Server transaction");
serverTransactionId = provider.getNewServerTransaction(notify);
}
Dialog dialog = serverTransactionId.getDialog();
if (dialog != subscriberDialog) {
forkedDialog = dialog;
}
//Dispatch the response along the route
dispatchExchange(notify.getContent());
// Send back an success response
Response response = sipSubscriber.getConfiguration().getMessageFactory().createResponse(200, notify);
response.addHeader(sipSubscriber.getConfiguration().getContactHeader());
serverTransactionId.sendResponse(response);
SubscriptionStateHeader subscriptionState = (SubscriptionStateHeader) notify
.getHeader(SubscriptionStateHeader.NAME);
// Subscription is terminated?
if (subscriptionState.getState().equalsIgnoreCase(SubscriptionStateHeader.TERMINATED)) {
LOG.info("Subscription state is terminated. Deleting the current dialog");
dialog.delete();
}
} catch (Exception e) {
LOG.error("Exception thrown during Notify processing in the SipSubscriptionListener.", e);
}
}
开发者ID:HydAu,项目名称:Camel,代码行数:36,代码来源:SipSubscriptionListener.java
示例3: processNotify
import javax.sip.header.SubscriptionStateHeader; //导入依赖的package包/类
public synchronized void processNotify(RequestEvent requestEvent,
ServerTransaction serverTransactionId) {
SipProvider provider = (SipProvider) requestEvent.getSource();
Request notify = requestEvent.getRequest();
try {
logger.info("subscriber: got a notify count " + this.count++);
if (serverTransactionId == null) {
logger.info("subscriber: null TID.");
serverTransactionId = provider.getNewServerTransaction(notify);
}
Dialog dialog = serverTransactionId.getDialog();
logger.info("Dialog = " + dialog);
if (dialog != null) {
logger.info("Dialog State = " + dialog.getState());
}
Response response = messageFactory.createResponse(200, notify);
// SHOULD add a Contact
ContactHeader contact = (ContactHeader) contactHeader.clone();
((SipURI) contact.getAddress().getURI()).setParameter("id", "sub");
response.addHeader(contact);
logger.info("Transaction State = " + serverTransactionId.getState());
serverTransactionId.sendResponse(response);
if (dialog != null) {
logger.info("Dialog State = " + dialog.getState());
}
SubscriptionStateHeader subscriptionState = (SubscriptionStateHeader) notify
.getHeader(SubscriptionStateHeader.NAME);
// Subscription is terminated?
String state = subscriptionState.getState();
if (state.equalsIgnoreCase(SubscriptionStateHeader.TERMINATED)) {
dialog.delete();
} else {
logger.info("Subscriber: state now " + state);
}
this.notifySeen = true;
} catch (Exception ex) {
ex.printStackTrace();
logger.error("Unexpected exception", ex);
fail("Unexpected exception");
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:47,代码来源:DeliverNotifyBefore202Test.java
示例4: processNotify
import javax.sip.header.SubscriptionStateHeader; //导入依赖的package包/类
private void processNotify(RequestEvent requestEvent,
ServerTransaction serverTransactionId) {
SipProvider provider = (SipProvider) requestEvent.getSource();
Request notify = requestEvent.getRequest();
if ( notify.getMethod().equals("NOTIFY") ) try {
logger.info("referer: got a NOTIFY count " + ++this.count + ":\n" + notify );
if (serverTransactionId == null) {
logger.info("referer: null TID.");
serverTransactionId = provider.getNewServerTransaction(notify);
}
Dialog dialog = serverTransactionId.getDialog();
logger.info("Dialog = " + dialog);
TestHarness.assertTrue("Dialog should not be null", dialog != null);
logger.info("Dialog State = " + dialog.getState());
Response response = messageFactory.createResponse(200, notify);
// SHOULD add a Contact
ContactHeader contact = (ContactHeader) contactHeader.clone();
((SipURI)contact.getAddress().getURI()).setParameter( "id", "sub" );
response.addHeader( contact );
logger.info("Transaction State = " + serverTransactionId.getState());
serverTransactionId.sendResponse(response);
logger.info("Dialog State = " + dialog.getState());
SubscriptionStateHeader subscriptionState = (SubscriptionStateHeader) notify
.getHeader(SubscriptionStateHeader.NAME);
// Subscription is terminated?
String state = subscriptionState.getState();
if (state.equalsIgnoreCase(SubscriptionStateHeader.TERMINATED)) {
dialog.delete();
} else {
logger.info("Referer: state now " + state);
}
} catch (Exception ex) {
TestHarness.fail("Failed processing notify, because of " + ex);
} else {
TestHarness.fail( "Unexpected request type" );
}
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:42,代码来源:Referrer.java
示例5: sendNotify
import javax.sip.header.SubscriptionStateHeader; //导入依赖的package包/类
private void sendNotify( int code, String reason )
throws SipException, ParseException
{
/*
* NOTIFY requests MUST contain a "Subscription-State" header with a
* value of "active", "pending", or "terminated". The "active" value
* indicates that the subscription has been accepted and has been
* authorized (in most cases; see section 5.2.). The "pending" value
* indicates that the subscription has been received, but that
* policy information is insufficient to accept or deny the
* subscription at this time. The "terminated" value indicates that
* the subscription is not active.
*/
Request notifyRequest = dialog.createRequest( "NOTIFY" );
// Initial state is pending, second time we assume terminated (Expires==0)
String state = SubscriptionStateHeader.PENDING;
if (code>100 && code<200) {
state = SubscriptionStateHeader.ACTIVE;
} else if (code>=200) {
state = SubscriptionStateHeader.TERMINATED;
}
SubscriptionStateHeader sstate = headerFactory.createSubscriptionStateHeader( state );
if (state == SubscriptionStateHeader.TERMINATED) {
sstate.setReasonCode("noresource");
}
notifyRequest.addHeader(sstate);
notifyRequest.setHeader(referEvent);
Address address = addressFactory.createAddress("Referee <sip:127.0.0.1>");
((SipURI)address.getURI()).setPort( mySipProvider.getListeningPoint(transport).getPort() );
((SipURI)address.getURI()).setTransportParam(transport);
ContactHeader contactHeader = headerFactory.createContactHeader(address);
notifyRequest.setHeader(contactHeader);
// notifyRequest.setHeader(routeHeader);
ClientTransaction ct2 = mySipProvider.getNewClientTransaction(notifyRequest);
ContentTypeHeader ct = headerFactory.createContentTypeHeader("message","sipfrag");
ct.setParameter( "version", "2.0" );
notifyRequest.setContent( "SIP/2.0 " + code + ' ' + reason, ct );
// Let the other side know that the tx is pending acceptance
//
dialog.sendRequest(ct2);
logger.info("NOTIFY Branch ID " +
((ViaHeader)notifyRequest.getHeader(ViaHeader.NAME)).getParameter("branch"));
logger.info("Dialog " + dialog);
logger.info("Dialog state after NOTIFY: " + dialog.getState());
}
开发者ID:YunlongYang,项目名称:LightSIP,代码行数:53,代码来源:Referee.java
示例6: sendNotification
import javax.sip.header.SubscriptionStateHeader; //导入依赖的package包/类
private void sendNotification(EventHeader eventHeader, boolean isInitial, Object body) throws SipException, ParseException {
/*
* NOTIFY requests MUST contain a "Subscription-State" header with a
* value of "active", "pending", or "terminated". The "active" value
* indicates that the subscription has been accepted and has been
* authorized (in most cases; see section 5.2.). The "pending" value
* indicates that the subscription has been received, but that
* policy information is insufficient to accept or deny the
* subscription at this time. The "terminated" value indicates that
* the subscription is not active.
*/
Request notifyRequest = dialog.createRequest("NOTIFY");
// Mark the contact header, to check that the remote contact is updated
((SipURI)sipPresenceAgent.getConfiguration().getContactHeader().getAddress().getURI()).setParameter(
sipPresenceAgent.getConfiguration().getFromUser(), sipPresenceAgent.getConfiguration().getFromHost());
SubscriptionStateHeader sstate;
if (isInitial) {
// Initial state is pending, second time we assume terminated (Expires==0)
sstate =
sipPresenceAgent.getConfiguration().getHeaderFactory().createSubscriptionStateHeader(isInitial ? SubscriptionStateHeader.PENDING : SubscriptionStateHeader.TERMINATED);
// Need a reason for terminated
if (sstate.getState().equalsIgnoreCase("terminated")) {
sstate.setReasonCode("deactivated");
}
} else {
sstate = sipPresenceAgent.getConfiguration().getHeaderFactory().createSubscriptionStateHeader(SubscriptionStateHeader.ACTIVE);
}
notifyRequest.addHeader(sstate);
notifyRequest.setHeader(eventHeader);
notifyRequest.setHeader(sipPresenceAgent.getConfiguration().getContactHeader());
notifyRequest.setContent(body, sipPresenceAgent.getConfiguration().getContentTypeHeader());
LOG.debug("Sending the following NOTIFY request to Subscriber: {}", notifyRequest);
ClientTransaction clientTransactionId = sipPresenceAgent.getProvider().getNewClientTransaction(notifyRequest);
dialog.sendRequest(clientTransactionId);
}
开发者ID:HydAu,项目名称:Camel,代码行数:43,代码来源:SipPresenceAgentListener.java
注:本文中的javax.sip.header.SubscriptionStateHeader类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论