DUM Creating New Client Subscriptions

From reSIProcate
Revision as of 13:21, 8 June 2010 by Sgodin (talk | contribs) (Created page with '==Setup Required in order to form a client Subscription== * To add support for the NOTIFY method mProfile->addSupportedMethod(NOTIFY); * To add support for receiving NOTIFY's w…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Setup Required in order to form a client Subscription

  • To add support for the NOTIFY method
mProfile->addSupportedMethod(NOTIFY); 
  • To add support for receiving NOTIFY's with the desired body type
mProfile->addSupportedMimeType(NOTIFY, Mime("application", "pidf+xml"));  
  • To add Support for handling the client subscription
mDum.addClientSubscriptionHandler("presence", mHandler);

Initiating SUBSCRIBE Requests

Sample Code:

SharedPtr<SipMessage> subMessage = dum.makeSubscription(presentityAor, "presence");
dum.send( subMessage );

Handling NOTIFY Requests

Sample Code (this same code can also be used in onUpdatePending and onUpdateExtension):

void
MyClientSubscription::onUpdateActive(ClientSubscriptionHandle h, const SipMessage& msg, bool outOfOrder)
{
   InfoLog(<< "onUpdatePending(ClientSubscriptionHandle): handle=" << mSubscriptionHandle << ", " << msg.brief());
   h->acceptUpdate();
   if(msg.getContents())
   {
      const Data& bodyData = msg.getContents()->getBodyData();
      ...handle body...
   }
}