reSIProcate/stack  9694
Classes | Public Member Functions | Private Member Functions | Private Attributes
Loadgen::InviteServer Class Reference

#include <InviteServer.hxx>

Collaboration diagram for Loadgen::InviteServer:
Collaboration graph
[legend]

List of all members.

Classes

class  Exception

Public Member Functions

 InviteServer (Transceiver &tranceiver)
void go ()

Private Member Functions

resip::SipMessagewaitForResponse (int responseCode, int waitMs)
resip::SipMessagewaitForRequest (resip::MethodTypes method, int waitMs)

Private Attributes

TransceivermTransceiver

Detailed Description

Definition at line 14 of file InviteServer.hxx.


Constructor & Destructor Documentation

InviteServer::InviteServer ( Transceiver tranceiver)

Definition at line 18 of file InviteServer.cxx.

   : mTransceiver(transceiver)
{}

Member Function Documentation

void InviteServer::go ( )

Definition at line 23 of file InviteServer.cxx.

References Loadgen::Transceiver::contactUri(), DebugLog, ErrLog, mTransceiver, Loadgen::Transceiver::send(), resip::NameAddr::uri(), resip::Uri::user(), and waitForRequest().

Referenced by main().

{
   NameAddr contact;
   contact.uri() = mTransceiver.contactUri();
   while (true)
   {
      try
      {
         auto_ptr<SipMessage> invite(waitForRequest(INVITE, 100000));
         contact.uri().user() = invite->header(h_RequestLine).uri().user();
         
         auto_ptr<SipMessage> i_100(Helper::makeResponse(*invite, 100, "Trying"));
         mTransceiver.send(*i_100);

         Data localTag = Helper::computeTag(4);

         auto_ptr<SipMessage> i_180(Helper::makeResponse(*invite, 180, contact, "Ringing"));
         i_180->header(h_To).uri().param(p_tag) = localTag;
         DebugLog(<< "constructed 180: " << *i_180);
         mTransceiver.send(*i_180);

         auto_ptr<SipMessage> i_200(Helper::makeResponse(*invite, 200, contact, "OK"));
         i_200->header(h_To).uri().param(p_tag) = localTag;
         mTransceiver.send(*i_200);
         
         auto_ptr<SipMessage> ack(waitForRequest(ACK, 1000));
         auto_ptr<SipMessage> bye(waitForRequest(BYE, 1000));

         auto_ptr<SipMessage> b_200(Helper::makeResponse(*bye, 200, contact, "OK"));
         mTransceiver.send(*b_200);
      }
      catch(Exception e)
      {
         ErrLog(<< "Proxy not responding.");
         exit(-1);
      }
   }
}

Here is the call graph for this function:

SipMessage * InviteServer::waitForRequest ( resip::MethodTypes  method,
int  waitMs 
) [private]

Definition at line 86 of file InviteServer.cxx.

References resip::RequestLine::getMethod(), resip::SipMessage::header(), resip::SipMessage::isRequest(), mTransceiver, and Loadgen::Transceiver::receive().

Referenced by go().

{
   SipMessage* req = mTransceiver.receive(waitMs);
   if(req)
   {         
      if (req->isRequest() &&
          req->header(h_RequestLine).getMethod() == method)
      {
         return req;
      }
      else
      {
         throw Exception("Invalid request.", __FILE__, __LINE__);
      }
   }
   else
   {
      throw Exception("Timed out.", __FILE__, __LINE__);
   }
}

Here is the call graph for this function:

SipMessage * InviteServer::waitForResponse ( int  responseCode,
int  waitMs 
) [private]

Definition at line 63 of file InviteServer.cxx.

References resip::SipMessage::header(), resip::SipMessage::isResponse(), mTransceiver, and Loadgen::Transceiver::receive().

{
   SipMessage* reg = mTransceiver.receive(waitMs);
   if(reg)
   {         
      if (reg->isResponse() &&
          reg->header(h_StatusLine).responseCode() == responseCode)
      {
         return reg;
      }
      else
      {
         throw Exception("Invalid response.", __FILE__, __LINE__);
      }
   }
   else
   {
      throw Exception("Timed out.", __FILE__, __LINE__);
   }
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 42 of file InviteServer.hxx.

Referenced by go(), waitForRequest(), and waitForResponse().


The documentation for this class was generated from the following files: