|
reSIProcate/stack
9694
|
#include <InviteServer.hxx>

Classes | |
| class | Exception |
Public Member Functions | |
| InviteServer (Transceiver &tranceiver) | |
| void | go () |
Private Member Functions | |
| resip::SipMessage * | waitForResponse (int responseCode, int waitMs) |
| resip::SipMessage * | waitForRequest (resip::MethodTypes method, int waitMs) |
Private Attributes | |
| Transceiver & | mTransceiver |
Definition at line 14 of file InviteServer.hxx.
| InviteServer::InviteServer | ( | Transceiver & | tranceiver | ) |
Definition at line 18 of file InviteServer.cxx.
: mTransceiver(transceiver) {}
| 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);
}
}
}

| 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__);
}
}

| 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__);
}
}

Transceiver& Loadgen::InviteServer::mTransceiver [private] |
Definition at line 42 of file InviteServer.hxx.
Referenced by go(), waitForRequest(), and waitForResponse().
1.7.5.1