reSIProcate/DialogUsageManager  9694
Classes | Defines | Functions
rlsServer.cxx File Reference
#include "resip/stack/SipStack.hxx"
#include "resip/dum/ClientAuthManager.hxx"
#include "resip/dum/ClientRegistration.hxx"
#include "resip/dum/ClientSubscription.hxx"
#include "resip/dum/DialogUsageManager.hxx"
#include "resip/dum/RegistrationHandler.hxx"
#include "resip/dum/Profile.hxx"
#include "resip/dum/PublicationHandler.hxx"
#include "resip/dum/SubscriptionHandler.hxx"
#include "resip/dum/ServerSubscription.hxx"
#include "rutil/Log.hxx"
#include "rutil/Logger.hxx"
#include "rutil/ParseBuffer.hxx"
#include "rutil/Subsystem.hxx"
#include "resip/dum/AppDialogSet.hxx"
#include "resip/dum/AppDialog.hxx"
#include "resip/dum/AppDialogSetFactory.hxx"
#include "resip/stack/Pidf.hxx"
#include "resip/stack/GenericContents.hxx"
#include <iostream>
#include <fstream>
Include dependency graph for rlsServer.cxx:

Go to the source code of this file.

Classes

class  RlsRegistrationHandler
class  RlsServerSubscriptionHandler
class  RlsServerSubscriptionHandler::RlsSubscription

Defines

#define RESIPROCATE_SUBSYSTEM   Subsystem::TEST

Functions

ContentsreadFromFile (string filename)
int main (int argc, char **argv)

Define Documentation

#define RESIPROCATE_SUBSYSTEM   Subsystem::TEST

Definition at line 26 of file rlsServer.cxx.


Function Documentation

int main ( int  argc,
char **  argv 
)

Definition at line 195 of file rlsServer.cxx.

References resip::DialogUsageManager::addServerSubscriptionHandler(), resip::DialogUsageManager::addTransport(), resip::Log::Cout, resip::Log::Debug, InfoLog, resip::Log::initialize(), resip::DialogUsageManager::makeRegistration(), resip::DialogUsageManager::process(), resip::FdSet::selectMilliSeconds(), resip::DialogUsageManager::send(), resip::DialogUsageManager::setClientRegistrationHandler(), and resip::UDP.

{
   if (argc == 1)
   {
      cerr << "Usage: rlsServer contentsFile (SPACE contentsFile) << endl";
      return -1;
   }
 
   Log::initialize(Log::Cout, Log::Debug, argv[0]);

   vector<string> inputFiles;
   for (int i = 1; i < argc; i++)
   {
      inputFiles.push_back(string(argv[i]));
   }

   RlsServerSubscriptionHandler subServerHandler(inputFiles);
   
   NameAddr from("sip:testRlsServer@internal.xten.net");
   Profile profile;   
   profile.setDefaultFrom(from);
   profile.clearSupportedMethods();
   profile.addSupportedMethod(SUBSCRIBE);   

   profile.validateAcceptEnabled() = false;
   profile.validateContentLanguageEnabled() = false;
   profile.validateContentEnabled() = false;

   DialogUsageManager dum;
   dum.addTransport(UDP, 15060);
//   dum.addTransport(TCP, 15060);

   dum.setProfile(&profile);
   dum.addServerSubscriptionHandler("presence", &subServerHandler);

   RlsRegistrationHandler regHandler;
   dum.setClientRegistrationHandler(&regHandler);

   SipMessage & regMessage = dum.makeRegistration(from);
   InfoLog( << regMessage << "Generated register: " << endl << regMessage );
   dum.send( regMessage );

   while (true)
   {
      FdSet fdset;
      dum.buildFdSet(fdset);
      int err = fdset.selectMilliSeconds(100);
      assert ( err != -1 );
      dum.process(fdset);
      
//         char c;
//         char str[256];
//         if (!cin.eof())
//         {
//            c=cin.get();
//            if ( c == 'n' || c == 'q') 
//            {
//               if (c == 'q')
//               {
//                  break;
//               }
//               else
//               {
//                  subServerHandler.sendNextNotify();
//               }
//            }
//            else
//            {
//               cin >> str;
//               cout << " You have entered [" << str << "] enter n to send the next notify or q to quit " << endl;
//            }
//         }
   }
   
   return 0;

}   

Here is the call graph for this function:

Contents* readFromFile ( string  filename)

Definition at line 50 of file rlsServer.cxx.

References resip::Symbols::CRLF, resip::Mime::parse(), resip::ParseBuffer::position(), resip::ParseBuffer::skipChars(), resip::ParseBuffer::skipWhitespace(), and resip::ParseBuffer::start().

Referenced by RlsServerSubscriptionHandler::RlsServerSubscriptionHandler().

{
   ifstream is;
   is.open (filename.c_str(), ios::binary );

   if (!is.good())
   {
      exit(-1);
   }

   // get length of file:
   is.seekg (0, ios::end);
   int length = is.tellg();
   is.seekg (0, ios::beg);

   // allocate memory:
   char* buffer = new char[length];

   // read data as a block:
   is.read (buffer,length);
   
   Mime mimeType;
   
   ParseBuffer pb(buffer, length);
   pb.skipChars("Content-Type:");
   pb.skipWhitespace();
   mimeType.parse(pb);   
   pb.skipChars(Symbols::CRLF);   
   
   HeaderFieldValue hfv(pb.position(), length - (pb.position() - pb.start()));
   GenericContents orig(&hfv, mimeType);
   
   GenericContents * copy = new GenericContents(orig);
   delete buffer;
   return copy;
}

Here is the call graph for this function: