< Previous by Date Date Index Next by Date >
< Previous in Thread Thread Index Next in Thread >

Re: [reSIProcate] How to maintain SUBSCRIBE AppDialogSets?


Thanks Scott,

So I should store Subscription handles that were taken from in the two callback functions?:

void onNewSubscription(ServerSubscriptionHandle is, const SipMessage& sub)
void onNewSubscription(ClientSubscriptionHandle, const SipMessage& notify)

How can I know the Subscription handles are still valid (alive)? Do I have to do it manual by tracking the status with callback functions:

void onTerminated(ClientSubscriptionHandle is, const SipMessage& msg)
virtual void onTerminated(ServerSubscriptionHandle)

And the last one: How can I re-send the subscribe messages (using the same Subscription handles)?

Thank you very much.

Regards,
DBQ.

On 5/4/07, Scott Godin <slgodin@xxxxxxxxxxxx> wrote:
>  
>  
>  
>
> Either way should work.  Storing subscription handles is easier to implement
> in a safe manner.
>
>  
>  
>  
>  
>
> From: Dien Ba Quang [mailto:dienbaquang@xxxxxxxxx]
>  Sent: Thursday, May 03, 2007 4:18 PM
>  To: Scott Godin
>  Cc: resiprocate-devel@xxxxxxxxxxxxxxxxxxxx
>  Subject: Re: [reSIProcate] How to maintain SUBSCRIBE AppDialogSets?
>  
>
>  
>
> Hi Scott,
>  
>  >>"When your app shuts down you should end() all subscriptions "
>  
>  Thank you for your instructions, but how can I end() all subscriptions?
> Call end() function from AppSetDialog class or
> ServerSubscriptionHandle/ClientSubscriptionHandle? So I
> should store all the SUBSCRIBE AppSetDialog or all the SUBSCRIBE handles?
>  
>  Thanks in advanced.
>  
>  Best reagrds,
>  DBQ.
>  
>  
>  
>
> On 5/3/07, Scott Godin <slgodin@xxxxxxxxxxxx> wrote:
>  
>  
>
> In general you should not be deleting AppDialogSets – DUM manages their
> lifetime and will delete them, when they are no longer required.  
>
> When your app shuts down you should end() all subscriptions and execute a
> dum->shutdown while running the process loop, when all dialogs are destroyed
> the shutdown callback will be called.
>
>  
>  
>  
>  
>
> From: resiprocate-devel-bounces@xxxxxxxxxxxxxxxxxxxx
> [mailto:resiprocate-devel-bounces@xxxxxxxxxxxxxxxxxxxx] On
> Behalf Of Dien Ba Quang
>  Sent: Thursday, May 03, 2007 11:35 AM
>  To: resiprocate-devel@xxxxxxxxxxxxxxxxxxxx
>  Subject: [reSIProcate] How to maintain SUBSCRIBE AppDialogSets?
>  
>
>  
>
> Hi,
>  In my soft phone, I implemented SUBSCRIBE and NOTIFY messages to maintain a
> buddy list. But I have some problems with the SUBSCRIBE AppDialogSets, it
> crashed sometimes. Below is my implementation:
>  After received 200 OK for REGISTER messages, send SUBSCRIBE messages for
> every contacts in my buddy list (code below).
>  
>  1. The problem is when I try to delete all the AppDialogSets (when closing
> soft phone), it crashed my app. So do you know how DUM deletes the
> AppDialogSet? and What's the good ways to maintain the SUBSCRIBE
> AppDialogSets?
>  2. When I repeated sending SUBSCRIBE messages from another instant (the
> same code) to the soft phone, it crashed (just sometime). I don't know
> what's the problem with DUM? It's always crash at line 775 in dialogset.cxx
>  
>  AppDialog* appDialog =
> mAppDialogSet->createAppDialog(msg);
>  
>  Best regards,
>  DBQ.
>  
>  void SendSubscribe(char* contact, int exp_time)
>  {
>      try {
>          string validContact = validateSipAddress(contact);
>          NameAddr uasAor(validContact.c_str());
>          Data mevent("presence");
>  
>          //Check if the contact already has the AppDialogSet or not
>          testAppDialogSet *m_pADS = uac.getSubscribeDialog(uasAor.uri());
>          if (m_pADS == NULL) //if not -> create a new one and store into a
> list(contact, group, AppDialogSet)
>          {
>              testAppDialogSet *m_pADS = new testAppDialogSet(*(clientDum),
> "UAC(SUBSCRIBE)");
>              uac.addBuddy(uasAor.uri(), "Friends", m_pADS);
>          }
>  
>          SharedPtr<SipMessage> SubscribeMessage =
> clientDum->makeSubscription(uasAor, mevent, exp_time,
> m_pADS);        
>          clientDum->send(SubscribeMessage);
>      }
>      catch (BaseException& e) {
>          return;
>      }
>  
>  //delete all SUBSCRIBE AppDialogSets
>  void TestUac::deleteSubscribeDialog()
>  {
>     TestUac::BuddyIterator i;
>     i = mBuddies.begin ();    
>     while ( i != mBuddies.end() )
>     {
>          if ( i->presDialog != NULL )
>          {
>              delete i->presDialog;
>              i->presDialog = NULL;
>          }
>          i = mBuddies.erase (i);
>     }
>  }
>  
>  //Subscription Callbacks
>  void TestUac::onUpdateActive(ClientSubscriptionHandle is,
> const SipMessage& notify, bool outOfOrder)
>  {
>      if (notify.header(h_Event).value() == Data("message-summary"))
>      {
>          is->acceptUpdate();
>          //TODO:check voice message
>  
>          return;
>      }
>      is->acceptUpdate();
>      Contents *body = notify.getContents ();
>      //Received NOTIFY message event with no contents
>      if (!body){
>          return;
>      }
>      Pidf* pidf = dynamic_cast<Pidf*>(body);    
>      Uri uri = pidf->getEntity();
>      //update status of uri as Online
>      PresenceNotify((char*)uri.user().c_str(), 1, 0);
>  }
>  
>  void TestUac::onNewSubscription(ServerSubscriptionHandle
> is, const SipMessage& sub)
>  {
>      SharedPtr<SipMessage> sipmsg = is->accept();
>      is->send(sipmsg);
>      Data fromAor(sub.header(h_From).uri().getAor());
>      string name = str_get_username(fromAor.c_str ());
>      if (sub.header(h_Expires).value() != 0){
>          Token state;
>          state.value() = Data("active");
>          Pidf *doc = new Pidf(Mime("application", "pidf-xml"));
>          doc->setEntity(myUri);
>          doc->setSimpleStatus(true);
>          sipmsg = is->update(doc);
>          sipmsg->header(h_SubscriptionState) = state;
>          is->send(sipmsg);
>          delete doc;
>  
>          //check if the name is not online --> resend SUBSCRIBE message
>          PresenceNotify((char*)name.c_str(), 1, 1);
>      }
>      else {
>          //in case Unsubscribe expire = 0
>          PresenceNotify((char*)name.c_str(), 0, 0);
>      }
>  }
>
>