[reSIProcate] How to maintain SUBSCRIBE AppDialogSets?
Dien Ba Quang
dienbaquang at gmail.com
Thu May 3 10:35:10 CDT 2007
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);
}
}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://list.resiprocate.org/pipermail/resiprocate-devel/attachments/20070503/f9867823/attachment.htm>
More information about the resiprocate-devel
mailing list