|
reSIProcate/DialogUsageManager
9694
|
#include "rutil/Log.hxx"#include "rutil/Logger.hxx"#include "rutil/Subsystem.hxx"#include "resip/dum/ClientAuthManager.hxx"#include "resip/dum/DialogUsageManager.hxx"#include "resip/dum/InviteSessionHandler.hxx"#include "resip/dum/MasterProfile.hxx"#include "resip/dum/Profile.hxx"#include "resip/dum/UserProfile.hxx"#include "resip/dum/PublicationHandler.hxx"#include "resip/dum/ClientPublication.hxx"#include "resip/dum/AppDialogSet.hxx"#include "resip/dum/AppDialog.hxx"#include "resip/stack/PlainContents.hxx"#include "resip/stack/Pidf.hxx"#include "rutil/Random.hxx"#include <iostream>#include <string>#include <sstream>
Go to the source code of this file.
Classes | |
| class | ClientPubHandler |
Defines | |
| #define | RESIPROCATE_SUBSYSTEM Subsystem::TEST |
Functions | |
| int | main (int argc, char *argv[]) |
Variables | |
| int | transCount = 0 |
| #define RESIPROCATE_SUBSYSTEM Subsystem::TEST |
Definition at line 32 of file basicPublication.cxx.
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 71 of file basicPublication.cxx.
References resip::DialogUsageManager::addClientPublicationHandler(), resip::DialogUsageManager::addTransport(), resip::SipStack::buildFdSet(), resip::DialogUsageManager::getMasterProfile(), resip::Pidf::getSimpleStatus(), ClientPubHandler::handle, InfoLog, resip::DialogUsageManager::makePublication(), resip::SipStack::process(), resip::DialogUsageManager::process(), resip::FdSet::selectMilliSeconds(), resip::DialogUsageManager::send(), resip::DialogUsageManager::setClientAuthManager(), resip::Pidf::setEntity(), resip::DialogUsageManager::setMasterProfile(), resip::Pidf::setSimpleId(), resip::Pidf::setSimpleStatus(), transCount, and UDP.
{
if( (argc < 5) || (argc > 6) ) {
cout << "usage: " << argv[0] << " sip:aor user passwd realm [port]\n";
return 0;
}
Log::initialize(Log::VSDebugWindow, Log::Debug, argv[0]);
bool first = true;
string aor(argv[1]);
string user(argv[2]);
string passwd(argv[3]);
string realm(argv[4]);
int port = 5060;
if(argc == 6) {
string temp(argv[5]);
istringstream src(temp);
src >> port;
}
Data eventName("presence");
InfoLog(<< "log: aor: " << aor << ", port: " << port << "\n");
InfoLog(<< "user: " << user << ", passwd: " << passwd << ", realm: " << realm << "\n");
// sip logic
SharedPtr<MasterProfile> profile(new MasterProfile);
auto_ptr<ClientAuthManager> clientAuth(new ClientAuthManager());
SipStack clientStack;
DialogUsageManager clientDum(clientStack);
clientDum.addTransport(UDP, port);
clientDum.setMasterProfile(profile);
clientDum.setClientAuthManager(clientAuth);
clientDum.getMasterProfile()->addSupportedMethod(PUBLISH);
clientDum.getMasterProfile()->addSupportedMimeType(PUBLISH,Pidf::getStaticType());
ClientPubHandler cph;
clientDum.addClientPublicationHandler(eventName,&cph);
NameAddr naAor(aor.c_str());
profile->setDefaultFrom(naAor);
profile->setDigestCredential(realm.c_str(), user.c_str(), passwd.c_str());
Pidf pidf;
pidf.setSimpleStatus(true);
pidf.setEntity(naAor.uri());
pidf.setSimpleId(Random::getRandomHex(3));
{
SharedPtr<SipMessage> pubMessage = clientDum.makePublication(naAor, profile,pidf,eventName,120);
InfoLog( << "Generated publish: " << endl << *pubMessage );
transCount++;
clientDum.send( pubMessage );
}
int nAttempts = 0;
bool bKeepGoing = true;
while(bKeepGoing)
{
FdSet fdset;
// Should these be buildFdSet on the DUM?
clientStack.buildFdSet(fdset);
int err = fdset.selectMilliSeconds(100);
assert ( err != -1 );
clientStack.process(fdset);
while(clientDum.process());
//if (!(n++ % 10)) cerr << "|/-\\"[(n/10)%4] << '\b';
if(transCount == 0) // No pending transactions.
{
nAttempts++;
if(nAttempts > 2)
bKeepGoing = false;
else
{
int nLoops = 1;
#ifdef PUB_REALLY_FAST
nLoops = 2;
#endif
for(int i = 0; i < nLoops; i++)
{
pidf.setSimpleStatus(!pidf.getSimpleStatus()); //toggle status
transCount++;
cph.handle->update(&pidf);
}
}
}
}
return 0;
}

| int transCount = 0 |
Definition at line 36 of file basicPublication.cxx.
Referenced by main(), ClientPubHandler::onFailure(), ClientPubHandler::onRemove(), and ClientPubHandler::onSuccess().
1.7.5.1