reSIProcate/stack  9694
Public Member Functions | Private Attributes
Server Class Reference
Inheritance diagram for Server:
Inheritance graph
[legend]
Collaboration diagram for Server:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 Server (SipStack &stack)
void thread ()
 Server (SipStack &stack, int numCalls, TransportType transport)
void thread ()

Private Attributes

SipStackmStack
int mNumCalls
TransportType mTransport

Detailed Description

Definition at line 118 of file testLockStep.cxx.


Constructor & Destructor Documentation

Server::Server ( SipStack stack) [inline]

Definition at line 122 of file testLockStep.cxx.

                              : mStack(stack)
      {}
Server::Server ( SipStack stack,
int  numCalls,
TransportType  transport 
) [inline]

Definition at line 29 of file testServer.cxx.

         : mStack(stack), 
           mNumCalls(numCalls),
           mTransport(transport)
      {}

Member Function Documentation

void Server::thread ( ) [inline, virtual]

Implements resip::ThreadIf.

Definition at line 35 of file testServer.cxx.

References resip::Helper::computeTag(), CritLog, ErrLog, resip::SipStack::getHostname(), resip::RequestLine::getMethod(), resip::Timer::getTimeMs(), resip::SipMessage::header(), resip::Uri::host(), InfoLog, resip::Helper::makeResponse(), resip::ParserCategory::param(), resip::Uri::port(), received, resip::Uri::scheme(), resip::FdSet::selectMilliSeconds(), resip::toData(), resip::NameAddr::uri(), and resip::Uri::user().

      {
         InfoLog(<<"This is the Server");

         UInt64 startTime = Timer::getTimeMs();

         NameAddr contact;
         contact.uri().scheme() = "sip";
         contact.uri().user() = "fluffy";
         
         contact.uri().host() = SipStack::getHostname();
         contact.uri().port() = 5070;
         contact.uri().param(p_transport) = Tuple::toData(mTransport);
         
         int calls = mNumCalls;
         while(calls > 0)
         {
            FdSet fdset;
            mStack.buildFdSet(fdset);
            int err = fdset.selectMilliSeconds(0);
            assert (err != -1);
            mStack.process(fdset);
            
            SipMessage* received = mStack.receive();
            if (received)
            {
               auto_ptr<SipMessage> forDel(received);
               MethodTypes meth = received->header(h_RequestLine).getMethod();
               ErrLog ( << "Server received: " << getMethodName(meth));
               if ( meth == INVITE )
               {
                  Data localTag = Helper::computeTag(4);
                  auto_ptr<SipMessage> msg180(Helper::makeResponse(*received, 180, contact));
                  msg180->header(h_To).param(p_tag) = localTag;
                  ErrLog( << "Sent 180");
                  mStack.send( *msg180);

                  auto_ptr<SipMessage> msg200(Helper::makeResponse(*received, 200, contact));
                  msg200->header(h_To).param(p_tag) = localTag;
                  ErrLog( << "Sent 200");
                  mStack.send(*msg200);
               }
               if ( meth == BYE)
               {
                  auto_ptr<SipMessage> msg200(Helper::makeResponse(*received, 200, contact));
                  calls--;
                  ErrLog( << "Sent 200 to BYE");
                  mStack.send(*msg200);
               }
            }
         }
         UInt64 endTime = Timer::getTimeMs();

         CritLog(<< "Completed: " << mNumCalls << " calls in " << endTime - startTime << "ms, " 
                 << mNumCalls*1000 / (float)(endTime - startTime) << " CPS");
      }

Here is the call graph for this function:

void Server::thread ( ) [inline, virtual]

Implements resip::ThreadIf.

Definition at line 125 of file testLockStep.cxx.

References resip::Message::brief(), resip::Helper::computeTag(), dest, resip::RequestLine::getMethod(), resip::SipMessage::header(), resip::Uri::host(), InfoLog, resip::Helper::makeResponse(), resip::ParserCategory::param(), resip::Uri::port(), received, resip::Uri::scheme(), resip::FdSet::selectMilliSeconds(), resip::NameAddr::uri(), and resip::Uri::user().

      {
         InfoLog(<<"This is the Server");

         NameAddr dest;
         dest.uri().scheme() = "sip";
         dest.uri().user() = "fluffy";
         dest.uri().host() = "localhost";
         dest.uri().port() = 5080;
         dest.uri().param(p_transport) = "tcp";

         while(true)
         {
            FdSet fdset;
            mStack.buildFdSet(fdset);
            int err = fdset.selectMilliSeconds(5);
            assert (err != -1);
            mStack.process(fdset);
            
            SipMessage* received = mStack.receive();
            if (received)
            {
               auto_ptr<SipMessage> forDel(received);
               InfoLog ( << "Server recieved: " << received->brief());
               MethodTypes meth = received->header(h_RequestLine).getMethod();
               if ( meth == INVITE )
               {
                  Data localTag = Helper::computeTag(4);
                  auto_ptr<SipMessage> msg180(Helper::makeResponse(*received, 180, dest));
                  msg180->header(h_To).param(p_tag) = localTag;
                  mStack.send( *msg180);
                  
                  auto_ptr<SipMessage> msg200(Helper::makeResponse(*received, 200, dest));
                  msg200->header(h_To).param(p_tag) = localTag;
                  mStack.send(*msg200);
               }
               if ( meth == BYE)
               {
                  auto_ptr<SipMessage> msg200(Helper::makeResponse(*received, 200, dest));
                  InfoLog (<< "stack2 got bye - send 200 : " << *msg200 );   
               
                  mStack.send(*msg200);
               }
            }
         }
      }

Here is the call graph for this function:


Member Data Documentation

int Server::mNumCalls [private]

Definition at line 93 of file testServer.cxx.

SipStack & Server::mStack [private]

Definition at line 172 of file testLockStep.cxx.

Definition at line 94 of file testServer.cxx.


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