|
reSIProcate/DialogUsageManager
9694
|
#include "rutil/Log.hxx"#include "rutil/Logger.hxx"#include "rutil/Subsystem.hxx"#include "resip/dum/ClientAuthManager.hxx"#include "resip/dum/ClientRegistration.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/RegistrationHandler.hxx"#include "resip/dum/ClientPagerMessage.hxx"#include "resip/dum/ServerPagerMessage.hxx"#include "resip/dum/AppDialogSet.hxx"#include "resip/dum/AppDialog.hxx"#include "resip/dum/PagerMessageHandler.hxx"#include "resip/stack/PlainContents.hxx"#include <iostream>#include <string>#include <sstream>
Go to the source code of this file.
Classes | |
| class | RegListener |
| class | ClientMessageHandler |
| class | ServerMessageHandler |
Defines | |
| #define | RESIPROCATE_SUBSYSTEM Subsystem::TEST |
Functions | |
| int | main (int argc, char *argv[]) |
| #define RESIPROCATE_SUBSYSTEM Subsystem::TEST |
Definition at line 31 of file basicMessage.cxx.
| int main | ( | int | argc, |
| char * | argv[] | ||
| ) |
Definition at line 107 of file basicMessage.cxx.
References resip::DialogUsageManager::addTransport(), client, resip::DialogUsageManager::getMasterProfile(), InfoLog, RegListener::isRegistered(), resip::DialogUsageManager::makePagerMessage(), resip::DialogUsageManager::makeRegistration(), resip::SipStack::process(), resip::DialogUsageManager::process(), resip::DialogUsageManager::send(), resip::DialogUsageManager::setClientAuthManager(), resip::DialogUsageManager::setClientPagerMessageHandler(), resip::DialogUsageManager::setClientRegistrationHandler(), resip::DialogUsageManager::setMasterProfile(), resip::DialogUsageManager::setServerPagerMessageHandler(), and UDP.
{
if( (argc < 6) || (argc > 7) ) {
cout << "usage: " << argv[0] << " sip:from user passwd realm sip:to [port]\n";
return 0;
}
Log::initialize(Log::Cout, Log::Info, argv[0]);
bool first = true;
string from(argv[1]);
string user(argv[2]);
string passwd(argv[3]);
string realm(argv[4]);
string to(argv[5]);
int port = 5060;
if(argc == 7) {
string temp(argv[6]);
istringstream src(temp);
src >> port;
}
InfoLog(<< "log: from: " << from << ", to: " << to << ", port: " << port << "\n");
InfoLog(<< "user: " << user << ", passwd: " << passwd << ", realm: " << realm << "\n");
// sip logic
RegListener client;
SharedPtr<MasterProfile> profile(new MasterProfile);
auto_ptr<ClientAuthManager> clientAuth(new ClientAuthManager());
SipStack clientStack;
DialogUsageManager clientDum(clientStack);
clientDum.addTransport(UDP, port);
clientDum.setMasterProfile(profile);
clientDum.setClientRegistrationHandler(&client);
clientDum.setClientAuthManager(clientAuth);
clientDum.getMasterProfile()->setDefaultRegistrationTime(70);
clientDum.getMasterProfile()->addSupportedMethod(MESSAGE);
clientDum.getMasterProfile()->addSupportedMimeType(MESSAGE, Mime("text", "plain"));
ClientMessageHandler *cmh = new ClientMessageHandler();
ServerMessageHandler *smh = new ServerMessageHandler();
clientDum.setClientPagerMessageHandler(cmh);
clientDum.setServerPagerMessageHandler(smh);
NameAddr naFrom(from.c_str());
profile->setDefaultFrom(naFrom);
profile->setDigestCredential(realm.c_str(), user.c_str(), passwd.c_str());
SharedPtr<SipMessage> regMessage = clientDum.makeRegistration(naFrom);
InfoLog( << *regMessage << "Generated register: " << endl << *regMessage );
clientDum.send( regMessage );
while(true) // (!cmh->isEnded() || !smh->isRcvd() )
{
clientStack.process(100);
while(clientDum.process());
//if (!(n++ % 10)) cerr << "|/-\\"[(n/10)%4] << '\b';
if(first && client.isRegistered()) {
first = false;
InfoLog(<<"client registered!!\n");
InfoLog(<< "Sending MESSAGE\n");
NameAddr naTo(to.c_str());
ClientPagerMessageHandle cpmh = clientDum.makePagerMessage(naTo);
auto_ptr<Contents> content(new PlainContents(Data("my first message!")));
cpmh.get()->page(content);
}
}
return 0;
}

1.7.5.1