|
reSIProcate/stack
9694
|


Public Member Functions | |
| Client (TransportType transport, const NameAddr &contact, const NameAddr &target) | |
| void | process (unsigned int timeoutMs) |
| Client (SipStack &stack) | |
| void | thread () |
Private Attributes | |
| SipStack | mStack |
| NameAddr | mContact |
| NameAddr | mTarget |
| bool | mWaitingForBye200 |
| SipStack & | mStack |
Definition at line 26 of file testClient.cxx.
| Client::Client | ( | TransportType | transport, |
| const NameAddr & | contact, | ||
| const NameAddr & | target | ||
| ) | [inline] |
Definition at line 29 of file testClient.cxx.
References resip::Helper::makeInvite(), resip::Uri::port(), and resip::NameAddr::uri().
: mStack(), mContact(contact), mTarget(target), mWaitingForBye200(false) { mStack.addTransport(transport, contact.uri().port()); auto_ptr<SipMessage> message(Helper::makeInvite( target, mContact, mContact)); mStack.send(*message); }

| Client::Client | ( | SipStack & | stack | ) | [inline] |
Definition at line 38 of file testLockStep.cxx.
: mStack(stack) {}
| void Client::process | ( | unsigned int | timeoutMs | ) | [inline] |
Definition at line 40 of file testClient.cxx.
References resip::Message::brief(), resip::DeprecatedDialog::createDialogAsUAC(), DebugLog, ErrLog, resip::SipMessage::header(), InfoLog, resip::SipMessage::isResponse(), resip::DeprecatedDialog::makeAck(), resip::DeprecatedDialog::makeBye(), resip::Helper::makeInvite(), and received.
Referenced by main().
{
mStack.process(timeoutMs);
SipMessage* received = mStack.receive();
if (received)
{
InfoLog (<< "Client received: " << received->brief());
auto_ptr<SipMessage> forDel(received);
if ( (received->isResponse()) )
{
if ( received->header(h_StatusLine).responseCode() == 200 )
{
if (!mWaitingForBye200)
{
ErrLog(<< "Creating dialog.");
DeprecatedDialog dlog(mContact);
DebugLog(<< "Creating dialog as UAC.");
dlog.createDialogAsUAC(*received);
DebugLog(<< "making ack.");
auto_ptr<SipMessage> ack(dlog.makeAck(*received) );
DebugLog(<< *ack);
DebugLog(<< "making bye.");
auto_ptr<SipMessage> bye(dlog.makeBye());
DebugLog(<< "Sending ack: << " << endl << *ack);
mStack.send(*ack);
DebugLog(<< "Sending bye: << " << endl << *bye);
mStack.send(*bye);
mWaitingForBye200 = true;
}
else
{
auto_ptr<SipMessage> message(Helper::makeInvite( mTarget, mContact, mContact));
mStack.send(*message);
mWaitingForBye200 = false;
}
}
}
}
}

| void Client::thread | ( | ) | [inline, virtual] |
Implements resip::ThreadIf.
Definition at line 41 of file testLockStep.cxx.
References resip::Message::brief(), resip::DeprecatedDialog::createDialogAsUAC(), DebugLog, dest, resip::SipMessage::header(), resip::Uri::host(), InfoLog, resip::SipMessage::isResponse(), resip::DeprecatedDialog::makeAck(), resip::DeprecatedDialog::makeBye(), resip::Helper::makeInvite(), resip::ParserCategory::param(), resip::Uri::port(), received, resip::Uri::scheme(), resip::FdSet::selectMilliSeconds(), resip::NameAddr::uri(), and resip::Uri::user().
{
InfoLog(<<"This is the Client");
NameAddr dest;
dest.uri().scheme() = "sip";
dest.uri().user() = "fluffy";
dest.uri().host() = "localhost";
dest.uri().port() = 5080;
dest.uri().param(p_transport) = "tcp";
NameAddr from = dest;
from.uri().port() = 5070;
Data count(1);
from.uri().user() = count;
{
auto_ptr<SipMessage> message(Helper::makeInvite( dest, from, from));
mStack.send(*message);
}
bool done = false;
//bool inviteState = true;
while(true)
{
FdSet fdset;
mStack.buildFdSet(fdset);
int err = fdset.selectMilliSeconds(5);
assert (err != -1);
mStack.process(fdset);
SipMessage* received = mStack.receive();
if (received)
{
InfoLog (<< "Client received: " << received->brief());
auto_ptr<SipMessage> forDel(received);
if ( (received->isResponse()) )
{
if ( received->header(h_StatusLine).responseCode() == 200 )
{
if (done)
{
break;
}
done = true;
DebugLog(<< "Creating dialog.");
DeprecatedDialog dlog(from);
DebugLog(<< "Creating dialog as UAC.");
dlog.createDialogAsUAC(*received);
DebugLog(<< "making ack.");
auto_ptr<SipMessage> ack(dlog.makeAck(*received) );
DebugLog(<< "making bye.");
auto_ptr<SipMessage> bye(dlog.makeBye());
DebugLog(<< "Sending ack: << " << endl << *ack);
mStack.send(*ack);
DebugLog(<< "Sending bye: << " << endl << *bye);
mStack.send(*bye);
}
}
}
usleep(1000);
}
}

NameAddr Client::mContact [private] |
Definition at line 88 of file testClient.cxx.
SipStack Client::mStack [private] |
Definition at line 87 of file testClient.cxx.
SipStack& Client::mStack [private] |
Definition at line 115 of file testLockStep.cxx.
NameAddr Client::mTarget [private] |
Definition at line 89 of file testClient.cxx.
bool Client::mWaitingForBye200 [private] |
Definition at line 90 of file testClient.cxx.
1.7.5.1