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

[reSIProcate-users] MessageDecorator question


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 :)