Logo Search packages:      
Sourcecode: yate version File versions  Download package

SIPTransaction::SIPTransaction ( SIPMessage message,
SIPEngine engine,
bool  outgoing = true 
)

Constructor from first message

Parameters:
message A pointer to the initial message, should not be used afterwards as the transaction takes ownership
engine A pointer to the SIP engine this transaction belongs
outgoing True if this transaction is for an outgoing request

Definition at line 33 of file transaction.cpp.

References TelEngine::ObjList::append(), TelEngine::String::clear(), TelEngine::Debug(), TelEngine::SIPMessage::getHeader(), getMethod(), TelEngine::SIPMessage::getParam(), TelEngine::SIPMessage::getParty(), Initial, TelEngine::RefObject::ref(), TelEngine::String::startsWith(), and TelEngine::SIPEngine::TransList.

    : m_outgoing(outgoing), m_invite(false), m_transmit(false), m_state(Invalid), m_timeout(0),
      m_firstMessage(message), m_lastMessage(0), m_pending(0), m_engine(engine), m_private(0)
{
    Debug(DebugAll,"SIPTransaction::SIPTransaction(%p,%p,%d) [%p]",
      message,engine,outgoing,this);
    if (m_firstMessage) {
      m_firstMessage->ref();

      const NamedString* ns = message->getParam("Via","branch");
      if (ns)
          m_branch = *ns;
      if (!m_branch.startsWith("z9hG4bK"))
          m_branch.clear();
      ns = message->getParam("To","tag");
      if (ns)
          m_tag = *ns;

      const HeaderLine* hl = message->getHeader("Call-ID");
      if (hl)
          m_callid = *hl;

      if (!m_outgoing && m_firstMessage->getParty()) {
          // adjust the address where we send the answers
          hl = message->getHeader("Via");
          if (hl) {
            URI uri(*hl);
            // skip over protocol/version/transport
            uri >> "/" >> "/" >> " ";
            uri.trimBlanks();
            uri = "sip:" + uri;
            m_firstMessage->getParty()->setParty(uri);
          }
      }
    }
    m_invite = (getMethod() == "INVITE");
    m_engine->TransList.append(this);
    m_state = Initial;
}


Generated by  Doxygen 1.6.0   Back to index