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

[reSIProcate] ClientSubscription HOWTO


I've been beating my head for the full day now trying to make SUBSCRIBE
work. Here is my scenario: 

After a connection is established (successful INVITE/ANSWER), I
overwrite InviteSession::onConnected(InviteSessionHandle h, const
SipMessage& msg) and try to subscribe to an event from calling party.
Initially I tried to use DialogUsageMangaer::makeSubscription to create
the request. But the call id and tags were totally different from the
established dialog. Then I modified AppDialog to return Dialog pointer,
and used the Dialog makeRequest for SUBSCRIBE. This turned out to be a
good message and the calling party accepted the request. The problem
arose when the calling party tried to send me the initial NOTIFY
request. The NOTIFY request was routed to the Dialog object. When Dialog
tried to dispatch it, it gave back a 406 response.

Here is the relevant code:

Creating and sending the SUBSCRIBE request:

void MtInviteSessionHandler::onConnected(InviteSessionHandle h, const
SipMessage& msg)
{
    cout << ": InviteSession-onConnected - " << msg.brief() << endl;
        
        //subscribe to kpml event notify
        SharedPtr<SipMessage> sub(new SipMessage());
        h->getAppDialog()->GetDialog()->makeRequest(*sub, SUBSCRIBE);
        sub->header(h_Event).value() = kpmlEvent.value(); 
        sub->header(h_Expires).value() =
h->getUserProfile()->getDefaultSubscriptionTime();
//      h->getUserProfile()->setDefaultFrom(msg.header(h_To));
//      SharedPtr<SipMessage> sub =
m_pRuntime->Dum()->makeSubscription(msg.header(h_From),
h->getUserProfile(), kpmlEvent.value());
//      sub->header(h_CallId) = msg.header(h_CallId);
        sub->header(h_RequestLine).uri().param(p_transport) =
Symbols::UDP;
        m_pRuntime->Dum()->send(sub);
}



I googled the net for some hints and I haven't found any. Any thoughts
on this topic would be greatly appreciated.

Thanks,

Hong