本文整理汇总了C++中SipMessage::getAcceptField方法的典型用法代码示例。如果您正苦于以下问题:C++ SipMessage::getAcceptField方法的具体用法?C++ SipMessage::getAcceptField怎么用?C++ SipMessage::getAcceptField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SipMessage
的用法示例。
在下文中一共展示了SipMessage::getAcceptField方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handleSubscribe
UtlBoolean SipSubscribeServer::handleSubscribe(const SipMessage& subscribeRequest)
{
UtlBoolean handledSubscribe = FALSE;
UtlString eventName;
subscribeRequest.getEventField(&eventName, NULL);
// Not modifying the SubscribeServerEventData, just reading it
lockForRead();
// Get the event specific handler and information
SubscribeServerEventData* eventPackageInfo =
dynamic_cast <SubscribeServerEventData*> (mEventDefinitions.find(&eventName));
// We handle this event type
if (eventPackageInfo)
{
handledSubscribe = TRUE;
SipSubscribeServerEventHandler* handler =
eventPackageInfo->mpEventSpecificHandler;
SipMessage subscribeResponse;
// Check if authenticated (or if it needs to be authenticated)
if (handler->isAuthenticated(subscribeRequest,
subscribeResponse))
{
// Check if authorized (or if authorization is required)
if (handler->isAuthorized(subscribeRequest,
subscribeResponse))
{
// The subscription is allowed, so update the
// subscription state. Set the To field tag if
// this request initiated the dialog
UtlString subscribeDialogHandle;
UtlBoolean isNewDialog;
UtlBoolean isExpiredSubscription;
UtlString resourceId, eventTypeKey, eventType;
eventPackageInfo->mpEventSpecificSubscriptionMgr->
updateDialogInfo(
subscribeRequest,
resourceId,
eventTypeKey,
eventType,
subscribeDialogHandle,
isNewDialog,
isExpiredSubscription,
subscribeResponse,
// The event-specific handler provides a getKeys method
// which is used to determine the resource ID
// and event type if this is a new subscription.
*handler);
// Build a NOTIFY
SipMessage notifyRequest;
// Set the dialog information into the NOTIFY.
// Note that the dialog can have ended by now, because of
// a race condition with the processing of dialog-ending
// messages from the outside world.
if (eventPackageInfo->mpEventSpecificSubscriptionMgr->
getNotifyDialogInfo(subscribeDialogHandle,
notifyRequest,
"active;expires=%ld"))
{
// We still have record of the dialog, so the
// NOTIFY headers were set.
// Set the NOTIFY content
UtlString acceptHeaderValue;
if (!subscribeRequest.getAcceptField(acceptHeaderValue))
{
// No Accept header seen, set special value allowing any
// content type.
acceptHeaderValue = SipPublishContentMgr::acceptAllTypes;
}
// Note that since this NOTIFY is due to a SUBSCRIBE,
// it should contain 'full' content. Hence,
// the fullState parameter of getNotifyContent is TRUE,
// and is not taken from
// eventPackageInfo->mEventSpecificFullState.
UtlString availableMediaTypes;
if (handler->getNotifyContent(resourceId,
eventTypeKey,
eventType,
*(eventPackageInfo->mpEventSpecificContentMgr),
acceptHeaderValue,
notifyRequest,
TRUE,
&availableMediaTypes))
{
// Update the NOTIFY content if required for this event type.
// Sets 'version' and 'eventTypeKey'.
int version;
eventPackageInfo->mpEventSpecificSubscriptionMgr->
updateNotifyVersion(eventPackageInfo->mpEventSpecificContentVersionCallback,
notifyRequest,
version,
eventTypeKey);
// Update the saved record of the NOTIFY CSeq and the
//.........这里部分代码省略.........
示例2: insertDialogInfo
UtlBoolean SipSubscriptionMgr::insertDialogInfo(const SipMessage& subscribeRequest,
const UtlString& resourceId,
const UtlString& eventTypeKey,
UtlString& subscribeDialogHandle,
UtlBoolean& isNew,
UtlBoolean& isSubscriptionExpired,
SipMessage& subscribeResponse)
{
isNew = FALSE;
UtlBoolean subscriptionSucceeded = FALSE;
UtlString dialogHandle;
subscribeRequest.getDialogHandle(dialogHandle);
SubscriptionServerState* state = NULL;
int expiration = -1;
isSubscriptionExpired = TRUE;
// If this is an early dialog we need to make it an established dialog.
if(SipDialog::isEarlyDialog(dialogHandle))
{
UtlString establishedDialogHandle;
if(mDialogMgr.getEstablishedDialogHandleFor(dialogHandle, establishedDialogHandle))
{
OsSysLog::add(FAC_SIP, PRI_WARNING,
"Incoming early SUBSCRIBE dialog: %s matches established dialog: %s",
dialogHandle.data(), establishedDialogHandle.data());
}
// make up a To tag and set it
UtlString toTag;
CallId::getNewTag(dialogHandle.data(), toTag);
// Get and validate the expires period
// This potentially should be delegated to the event handler specifics
if(!subscribeRequest.getExpiresField(&expiration))
{
expiration = mDefaultExpiration;
}
else if(expiration > mMaxExpiration)
{
expiration = mMaxExpiration;
}
// Acceptable expiration, create a subscription and dialog
if(expiration >= mMinExpiration ||
expiration == 0 ||
// :WORKAROUND: Also allow expiration == 1, to support the
// 1-second subscriptions the pick-up agent makes because
// current Snom phones do not respond to 0-second subscriptions.
// See XPB-399 and ENG-319.
expiration == 1)
{
// Create a dialog and subscription state even if
// the expiration is zero as we need the dialog info
// to route the one-time NOTIFY. The immediately
// expired dialog will be garbage collected.
SipMessage* subscribeCopy = new SipMessage(subscribeRequest);
subscribeCopy->setToFieldTag(toTag);
// Re-get the dialog handle now that the To tag is set
subscribeCopy->getDialogHandle(dialogHandle);
// Create the dialog
mDialogMgr.createDialog(*subscribeCopy, FALSE, dialogHandle);
isNew = TRUE;
// Create a subscription state
state = new SubscriptionServerState();
*((UtlString*) state) = dialogHandle;
state->mEventTypeKey = eventTypeKey;
state->mpLastSubscribeRequest = subscribeCopy;
state->mResourceId = resourceId;
subscribeCopy->getAcceptField(state->mAcceptHeaderValue);
long now = OsDateTime::getSecsSinceEpoch();
state->mExpirationDate = now + expiration;
// TODO: currently the SipSubsribeServer does not handle timeout
// events to send notifications that the subscription has ended.
// So we do not set a timer at the end of the subscription
state->mpExpirationTimer = NULL;
// Create the index by resourceId and eventTypeKey key
SubscriptionServerStateIndex* stateKey = new SubscriptionServerStateIndex;
*((UtlString*) stateKey) = resourceId;
stateKey->append(eventTypeKey);
stateKey->mpState = state;
subscribeResponse.setResponseData(subscribeCopy,
SIP_ACCEPTED_CODE,
SIP_ACCEPTED_TEXT,
NULL);
subscribeResponse.setExpiresField(expiration);
subscribeCopy->getDialogHandle(subscribeDialogHandle);
lock();
mSubscriptionStatesByDialogHandle.insert(state);
mSubscriptionStateResourceIndex.insert(stateKey);
if (OsSysLog::willLog(FAC_SIP, PRI_DEBUG))
//.........这里部分代码省略.........
示例3: handleSubscribe
UtlBoolean SipSubscribeServer::handleSubscribe(const SipMessage& subscribeRequest)
{
UtlBoolean handledSubscribe = FALSE;
UtlString eventName;
subscribeRequest.getEventField(&eventName, NULL);
// Not modifying the SubscribeServerEventData, just reading it
lockForRead();
// Get the event specific handler and information
SubscribeServerEventData* eventPackageInfo = (SubscribeServerEventData*)
mEventDefinitions.find(&eventName);
// We handle this event type
if(eventPackageInfo)
{
handledSubscribe = TRUE;
UtlString resourceId;
UtlString eventTypeKey, eventType;
SipSubscribeServerEventHandler* handler =
eventPackageInfo->mpEventSpecificHandler;
// Get the keys used to identify the event state content
handler->getKeys(subscribeRequest,
resourceId,
eventTypeKey,
eventType);
SipMessage subscribeResponse;
// Check if authenticated (or if it needs to be authenticated)
if(handler->isAuthenticated(subscribeRequest,
resourceId,
eventTypeKey,
subscribeResponse))
{
// Check if authorized (or if authorization is required)
if(handler->isAuthorized(subscribeRequest,
resourceId,
eventTypeKey,
subscribeResponse))
{
// The subscription is allowed, so update the
// subscription state. Set the To field tag if
// this request initiated the dialog
UtlString subscribeDialogHandle;
UtlBoolean isNewDialog;
UtlBoolean isExpiredSubscription;
eventPackageInfo->mpEventSpecificSubscriptionMgr->updateDialogInfo(
subscribeRequest,
resourceId,
eventTypeKey,
getMessageQueue(),
subscribeDialogHandle,
isNewDialog,
isExpiredSubscription,
subscribeResponse);
// Send the response ASAP to minimize resend handling of request
eventPackageInfo->mpEventSpecificUserAgent->send(subscribeResponse);
// Build a NOTIFY
SipMessage notifyRequest;
// Set the dialog information
eventPackageInfo->mpEventSpecificSubscriptionMgr->getNotifyDialogInfo(subscribeDialogHandle,
notifyRequest);
// Set the NOTIFY content
UtlString acceptHeaderValue;
subscribeRequest.getAcceptField(acceptHeaderValue);
handler->getNotifyContent(resourceId,
eventTypeKey,
eventType,
*(eventPackageInfo->mpEventSpecificContentMgr),
acceptHeaderValue,
notifyRequest);
// Send the notify request
eventPackageInfo->mpEventSpecificUserAgent->send(notifyRequest);
}
// Not authorized
else
{
// Send the response
eventPackageInfo->mpEventSpecificUserAgent->send(subscribeResponse);
}
}
// Not authenticated
else
{
// Send the response
eventPackageInfo->mpEventSpecificUserAgent->send(subscribeResponse);
}
}
// We should not have received SUBSCRIBE requests for this event type
// This event type has not been enabled in this SubscribeServer
//.........这里部分代码省略.........
示例4: updateDialogInfo
//.........这里部分代码省略.........
// 1-second subscriptions the pick-up agent makes because
// current Snom phones do not respond to 0-second subscriptions.
// See XPB-399 and ENG-319.
expiration == 1)
{
// Call the event-specific function to determine the resource ID
// and event type for this SUBSCRIBE.
handler.getKeys(subscribeRequest,
resourceId,
eventTypeKey,
eventType);
// Create a dialog and subscription state even if
// the expiration is zero as we need the dialog info
// to route the one-time NOTIFY. The immediately
// expired dialog will be garbage collected.
SipMessage* subscribeCopy = new SipMessage(subscribeRequest);
subscribeCopy->setToFieldTag(toTag);
// Re-get the dialog handle now that the To tag is set
subscribeCopy->getDialogHandle(dialogHandle);
// Create the dialog
mDialogMgr.createDialog(*subscribeCopy, FALSE, dialogHandle);
isNew = TRUE;
// Create a subscription state
state = new SubscriptionServerState();
*((UtlString*) state) = dialogHandle;
state->mEventTypeKey = eventTypeKey;
state->mpLastSubscribeRequest = subscribeCopy;
state->mResourceId = resourceId;
subscribeCopy->getAcceptField(state->mAcceptHeaderValue);
long now = OsDateTime::getSecsSinceEpoch();
state->mExpirationDate = now + expiration;
// TODO: currently the SipSubsribeServer does not handle timeout
// events to send notifications that the subscription has ended.
// So we do not set a timer at the end of the subscription
state->mpExpirationTimer = NULL;
// Create the index by resourceId and eventTypeKey key
SubscriptionServerStateIndex* stateKey = new SubscriptionServerStateIndex;
*((UtlString*) stateKey) = resourceId;
stateKey->append(eventTypeKey);
stateKey->mpState = state;
subscribeResponse.setResponseData(subscribeCopy,
SIP_ACCEPTED_CODE,
SIP_ACCEPTED_TEXT,
NULL);
subscribeResponse.setExpiresField(expiration);
subscribeCopy->getDialogHandle(subscribeDialogHandle);
lock();
mSubscriptionStatesByDialogHandle.insert(state);
mSubscriptionStateResourceIndex.insert(stateKey);
if (OsSysLog::willLog(FAC_SIP, PRI_DEBUG))
{
UtlString requestContact;
subscribeRequest.getContactField(0, requestContact);
OsSysLog::add(FAC_SIP, PRI_DEBUG,
"SipSubscriptionMgr::updateDialogInfo insert early-dialog subscription for dialog handle '%s', key '%s', contact '%s', mExpirationDate %ld",
state->data(), stateKey->data(),