implement more Message ops

git-svn-id: https://svn.resiprocate.org/rep/resiprocate/main@8072 ddefafc4-47db-0310-ae44-fa13212b10f2
This commit is contained in:
Jason Fischl
2008-06-19 01:42:39 +00:00
parent e4bd291fb2
commit 1d24393a69
4 changed files with 32 additions and 6 deletions

View File

@@ -89,6 +89,13 @@ DestinationId::operator==(const DestinationId& nid) const
return false;
}
s2c::DestinationStruct*
DestinationId::copyDestinationStruct() const
{
return new s2c::DestinationStruct(*this);
}
/* ======================================================================

View File

@@ -27,6 +27,8 @@ class DestinationId : private s2c::DestinationStruct
bool operator==(const NodeId& nid) const;
bool operator==(const DestinationId& nid) const;
s2c::DestinationStruct* copyDestinationStruct() const;
};
}

View File

@@ -252,11 +252,19 @@ Message::parse(const resip::Data &message)
void
Message::copyForwardingData(const Message &header)
{
mPDU.mHeader->mOverlay = header.mPDU.mHeader->mOverlay;
mPDU.mHeader->mTransactionId = header.mPDU.mHeader->mTransactionId;
assert(header.isRequest());
mPDU.mHeader->mOverlay = header.mPDU.mHeader->mOverlay;
mPDU.mHeader->mTransactionId = header.mPDU.mHeader->mTransactionId;
assert(mPDU.mHeader->mDestinationList.empty());
std::vector<DestinationStruct*>::reverse_iterator i;
for (i=header.mPDU.mHeader->mViaList.rbegin(); i!=header.mPDU.mHeader->mViaList.rend(); ++i)
{
DestinationStruct* ds = new DestinationStruct(**i);
mPDU.mHeader->mDestinationList.push_back(ds);
}
}
void
Message::decrementTTL()
{
@@ -442,11 +450,19 @@ Message::event()
}
void
Message::pushVia(NodeId id)
Message::pushVia(const DestinationId& did)
{
assert(0);
assert(!did.isResourceId());
mPDU.mHeader->mViaList.push_back(did.copyDestinationStruct());
}
void
Message::pushDestinationId(const DestinationId& did)
{
mPDU.mHeader->mDestinationList.push_back(did.copyDestinationStruct());
}
/* ======================================================================
* Copyright (c) 2008, Various contributors to the Resiprocate project
* All rights reserved.

View File

@@ -107,7 +107,8 @@ class Message : public Signable
UInt32 getOverlay() const;
UInt64 getTransactionId() const;
UInt16 getFlags() const;
void pushVia(NodeId node);
void pushVia(const DestinationId& node);
void pushDestinationId(const DestinationId& did);
NodeId getResponseNodeId() const; // pull this from the via list