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

Re: [reSIProcate-users] Added message body and headers not included during re-subscription


I haven't had anytime to try this out myself, but I do not see
anything specific in the code that would cause this.

I'll outline the process used by DUM so that you can try to debug and
use break points and in strategic locations to track down which step
the custom headers appear to missing.  When you call makeSubscription
you are given back a SmartPtr to the message that is stored in
SubscriptionCreator::mLastRequest.  When you modify the message
pointed to by this pointer, then you will be modifiying the
SubscriptionCreator(BaseCreator) stored copy.  Once the first NOTFY is
received the ClientSubscription is created (Dialog.cxx line 560), and
the message stored in the SubscriptionCreator is passed/copied to the
ClientSubscription constructor and stored in
ClientSubscription::mLastRequest (all custom headers should still be
in tact).  ClientSubscription then uses this stored message to form
all refresh messages by calling:  mDialog.makeRequest(*mLastRequest,
SUBSCRIBE) - custom headers should still be tact.

Scott

On Tue, Jan 6, 2009 at 2:22 AM, Wong Kok Meng-a17866
<kokmeng.wong@xxxxxxxxxxxx> wrote:
> Hi,
>
> Again on this topic, I'm encountering another problem but is similar.
> This is my code:
>
>  // create SUBSCRIBE message
>  SharedPtr<SipMessage> msg;
>  msg = Dum.makeSubscription(targetUri, event.c_str());
>
>  // add extra headers and parameters
>  msg->header(h_Contacts).front().param(p_g3gppappref) =
> "urn%3Aurn-xxx%3A3gpp-service.ims.iptv";
>  msg->header(h_AcceptContacts).push_back(NameAddr("*"));
>  msg->header(h_AcceptContacts).front().param(p_g3gppappref) =
> "urn%3Aurn-xxx%3A3gpp-service.ims.iptv";
>
> msg->header(h_PPreferredService).push_back(resip::StringCategory("urn:ur
> n-xxx:3gpp-service.ims.iptv");
>
> msg->header(h_PPreferredIdentities).push_back(userProfile->getDefaultFro
> m());
>
>  // send SUBSCRIBE messge
>  Dum.send(msg);
>
> h_PPreferredService is an extension header, p_g3gppappref is an
> extension parameter.
>
> In the first subscription, all the customized headers and parameters are
> seen in the SUBSCRIPTION message. However, in the next subscription
> refreshes, h_Contacts and p_g3gppappref are there. However, the rests of
> the customized headers are dropped.
>
> Is this behaviour expected? Did I do anything wrong in the code? Is
> there a way to overcome this problem?
>
> Thank you very much for your time.
>
> Regards,
> Kok Meng, Wong
>
> -----Original Message-----
> From: slgodin@xxxxxxxxx [mailto:slgodin@xxxxxxxxx] On Behalf Of Scott
> Godin
> Sent: Wednesday, December 17, 2008 5:56 AM
> To: Wong Kok Meng-a17866
> Cc: resiprocate-users@xxxxxxxxxxxxxxx
> Subject: Re: [reSIProcate-users] Added message body and headers not
> included during re-subscription
>
> >From examing the code it seems that the message body should be
> preserved for refreshes, however if any of the following occur, then
> it seems that a completely new subscription is created where any
> custom changes to the original Subscribe message will not be preserved
> (see occurances of mDum.makeSubscription in ClientSubscription.cxx:
> 1. a 481 response is received
> 2. a 408, 413, 480, 486, 500, 503, 600 or 603 error is received with a
> Retry-After header.
>
> In your code, make sure you are modifying the SipMessage pointed to by
> the SharedPtr returned from the mDum.makeSubscription call (as you are
> in the sample code you included).
>
> Also a slightly cleaner/safer way of adding the message body would be
> something like:
> Data xmlBodyData = .....;
> Mime type("text", "xml");
> OctetContents contents(xmlBodyData, type);
> msg->addContents(&contents);
>
> Scott
>
> On Mon, Dec 15, 2008 at 2:57 AM, Wong Kok Meng-a17866
> <kokmeng.wong@xxxxxxxxxxxx> wrote:
>> Hi,
>>
>> I create a SUBSCRIBE message using
> DialogUsageManager::makeSubscription(). I
>> add a message body and a couple message headers to the SUBSCRIBE
> message. I
>> then use DialogUsageManager::send() to send out the SUBSCRIBE message.
> It
>> looks good for the first SUBSCRIBE message. When the subscription
> expiry
>> timer expires, it does a refresh subscription. However, in the
> re-SUBSCRIBE
>> message, I don't see the message body and message headers that are
> added by
>> me. My code looks something like this:
>>
>>   // create SUBSCRIBE message
>>   SharedPtr<SipMessage> msg;
>>   msg = Dum.makeSubscription(targetUri, event.c_str());
>>
>>   // add message body and headers
>>   std:string body = "<some values>";
>>   msg->header(h_ContentType).type() = "text";
>>   msg->header(h_ContentType).subtype() = "xml";
>>   char *buf = new char[body.size() + 1];
>>   msg->addBuffer(buf);
>>   strcpy(buf, body.c_str());
>>   msg->setBody(buf, body.size());
>>
>>   // send SUBSCRIBE messge
>>   Dum.send(msg);
>>
>> The way I use to overcome this problem is to re-include the message
> body and
>> header in the function ClientSubscriptionHandler::onReadyToSend(). Are
> there
>> other recommended ways?
>>
>> Thank you.
>>
>> Regards,
>> Kok Meng
>>
>> _______________________________________________
>> resiprocate-users mailing list
>> resiprocate-users@xxxxxxxxxxxxxxx
>> List Archive: http://list.resiprocate.org/archive/resiprocate-users/
>>
> _______________________________________________
> resiprocate-users mailing list
> resiprocate-users@xxxxxxxxxxxxxxx
> List Archive: http://list.resiprocate.org/archive/resiprocate-users/
>