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

Re: [reSIProcate-users] MessageDecorator question


The purpose is to have code that can undo the decoration; the reason this crops up is because of how the stack behaves when it gets a 503 with a Retry-After; if there are other DNS results to send the message to, it will go ahead and try. Since we are now sending to a different destination, the decorator needs to be given a chance to run again (because it might need to decorate it differently). And if it is going to be run again, it needs to undo the previous changes first.

Best regards,
Byron Campen

Greetings.
What is the purpose of MessageDecorator::rollbackMessage() method? How to override it properly?

Now I use the following code to decorate messages in STUN environment:

class STUNDecorator: public MessageDecorator
{
protected:
 SIPEndPoint&  mEndPoint;
 SipMessage    mOriginalMsg;

public:
 STUNDecorator(SIPEndPoint& endpoint)
   :mEndPoint(endpoint)
 {
 }

 virtual ~STUNDecorator()
 {
 }

virtual void decorateMessage(SipMessage &msg, const resip::Tuple &source, const resip::Tuple &destination)
 {
   mOriginalMsg = msg;

if (/*mEndPoint.mStunHost.empty() && */ mEndPoint.mUseExternalIP && !mEndPoint.mStunHost.empty() && mEndPoint.mStunEnabled)
   {
     if (msg.header(h_Vias).size() > 0)
     {
msg.header(h_Vias).front().sentHost() = Data(mEndPoint.mExternalIP); msg.header(h_Vias).front().sentPort() = mEndPoint.mExternalPort;
     }

     if (msg.header(h_Contacts).size() > 0)
     {
msg.header(h_Contacts).front().uri().port() = mEndPoint.mExternalPort; msg.header(h_Contacts).front().uri().host() = resip::Data(mEndPoint.mExternalIP);
     }
   }
 }

 virtual void rollbackMessage(SipMessage& msg)
 {
if (mEndPoint.mUseExternalIP && !mEndPoint.mStunHost.empty() && mEndPoint.mStunEnabled)
   {
     msg = mOriginalMsg;
   }
 }

Sometimes user agent failes on assignment msg = mOriginalMsg. To be precise: it fails on assignment of mDestination.

Now I commented out the rollbackMessage implementation (just empty method) to make workaround... Is it ok?

Thank you :)
_______________________________________________
resiprocate-users mailing list
resiprocate-users@xxxxxxxxxxxxxxx
List Archive: http://list.resiprocate.org/archive/resiprocate-users/

Attachment: smime.p7s
Description: S/MIME cryptographic signature