< Previous by Date | Date Index | Next by Date > |
< Previous in Thread | Thread Index | Next in Thread > |
You
need to dynamic cast the Message pointer and if it’s 0 then it’s
not a SipMessage and you should ignore it. Also,
I think you still need to make a copy of the HeaderFieldValue to allocate a
buffer that is owned by the underlying HeaderFieldValue. Untested
code: DumFeature::ProcessingResult
MyFeature::process(Message* msg) SipMessage* sipMsg = dynamic_cast<SipMessage*>(msg); if (sipMsg) { const resip::Data headerName("User-Agent"); resip::Data headerValue("test"); Headers::Type headerType =
Headers::getType(headerName.data(), headerName.size()); if (headerType != Headers::UNKNOWN) { HeaderFieldValueList * hfvs = new
HeaderFieldValueList(); hfvs->push_back(new
HeaderFieldValue(HeaderFieldValue(headerValue.data(), headerValue.size()))); sipMsg->setRawHeader(hfvs,
headerType); } } postCommand(auto_ptr<Message>(sipMsg)); return
DumFeature::FeatureDone; } From:
resiprocate-devel-bounces@xxxxxxxxxxxxxxx
[mailto:resiprocate-devel-bounces@xxxxxxxxxxxxxxx] On Behalf Of Karlsson Hi all, I have write a class which derived from DumFeature,
and implemented the process function: DumFeature::ProcessingResult MyFeature::process(Message*
msg) SipMessage* sipMsg = (SipMessage*)msg; resip::HeaderBase * headerBase =
HeaderBase::getInstance(resip::Headers::getType(headerName.c_str(),headerName.size())); if (headerBase)
sipMsg->setRawHeader(hfvs,
Headers::getType(headerName.data(), headerName.size())); } postCommand(auto_ptr<Message>(sipMsg)); return DumFeature::FeatureDone; My application is crashed on sipMsg->remove(*headerBase);
I have debug this function: void Above code I have using with MessageDecorator::decorateMessage
function, it's working fine. And I try to use SipMessage* sipMsg =
dynamic_cast<SipMessage*>(msg); to instead SipMessage*
sipMsg = (SipMessage*)msg; but it's failed, the dynamic_cast
result it 0. Thanks |