/[resiprocate]/main/resip/dum/test/UserAgent.cxx
ViewVC logotype

Diff of /main/resip/dum/test/UserAgent.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 4078 by jason, Wed Mar 30 18:00:53 2005 UTC revision 4383 by jason, Sun Apr 17 20:50:58 2005 UTC
# Line 20  Line 20 
20    
21  UserAgent::UserAgent(int argc, char** argv) :  UserAgent::UserAgent(int argc, char** argv) :
22     CommandLineParser(argc, argv),     CommandLineParser(argc, argv),
23       mProfile(),
24  #if defined(USE_SSL)  #if defined(USE_SSL)
25     mSecurity(new Security(mCertPath)),     mSecurity(new Security(mCertPath)),
26     mDum(mSecurity)     mStack(mSecurity),
27  #else  #else
28     mSecurity(0),     mSecurity(0),
29     mDum(mSecurity)     mStack(mSecurity),
30  #endif  #endif
31       mDum(mStack),
32       mStackThread(mStack)
33  {  {
34     Log::initialize(mLogType, mLogLevel, argv[0]);     Log::initialize(mLogType, mLogLevel, argv[0]);
35    
# Line 39  Line 42 
42    
43     addTransport(UDP, mUdpPort);     addTransport(UDP, mUdpPort);
44     addTransport(TCP, mTcpPort);     addTransport(TCP, mTcpPort);
45    #if defined(USE_SSL)
46     addTransport(TLS, mTlsPort);     addTransport(TLS, mTlsPort);
47    #endif
48    #if defined(USED_DTLS)
49     addTransport(DTLS, mDtlsPort);     addTransport(DTLS, mDtlsPort);
50    #endif
51    
52     mProfile.setDefaultRegistrationTime(mRegisterDuration);     mProfile.setDefaultRegistrationTime(mRegisterDuration);
53     mProfile.addSupportedMethod(NOTIFY);     mProfile.addSupportedMethod(NOTIFY);
# Line 48  Line 55 
55     mProfile.validateContentEnabled() = false;     mProfile.validateContentEnabled() = false;
56     mProfile.addSupportedMimeType(NOTIFY, Pidf::getStaticType());     mProfile.addSupportedMimeType(NOTIFY, Pidf::getStaticType());
57     mProfile.setDefaultFrom(NameAddr(mAor));     mProfile.setDefaultFrom(NameAddr(mAor));
58       mProfile.setDigestCredential(mAor.host(), mAor.user(), mPassword);
59      
60     if (!mContact.host().empty())     if (!mContact.host().empty())
61     {     {
62        mProfile.setOverrideHostAndPort(mContact);        mProfile.setOverrideHostAndPort(mContact);
# Line 56  Line 65 
65     {     {
66        mProfile.setOutboundProxy(Uri(mOutboundProxy));        mProfile.setOutboundProxy(Uri(mOutboundProxy));
67     }     }
68     mProfile.setUserAgent("limpc/0.3");     mProfile.setUserAgent("limpc/1.0");
69        
70     mDum.setMasterProfile(&mProfile);     mDum.setMasterProfile(&mProfile);
71     mDum.setClientRegistrationHandler(this);     mDum.setClientRegistrationHandler(this);
# Line 66  Line 75 
75     mDum.setClientAuthManager(std::auto_ptr<ClientAuthManager>(new ClientAuthManager));     mDum.setClientAuthManager(std::auto_ptr<ClientAuthManager>(new ClientAuthManager));
76     mDum.setInviteSessionHandler(this);     mDum.setInviteSessionHandler(this);
77        
78     mDum.run(); // starts a StackThread     mStackThread.run();
79  }  }
80    
81  UserAgent::~UserAgent()  UserAgent::~UserAgent()
82  {  {
83     shutdown();     mStackThread.shutdown();
84     join();     mStackThread.join();
85  }  }
86    
87  void  void
# Line 80  Line 89 
89  {  {
90     if (mRegisterDuration)     if (mRegisterDuration)
91     {     {
92          InfoLog (<< "register for " << mAor);
93        mDum.send(mDum.makeRegistration(NameAddr(mAor)));        mDum.send(mDum.makeRegistration(NameAddr(mAor)));
94     }     }
95    
# Line 107  Line 117 
117  void  void
118  UserAgent::process()  UserAgent::process()
119  {  {
120     mDum.process();     while (mDum.process());
121  }  }
122    
123  void  void
 UserAgent::thread()  
 {  
    while(!waitForShutdown(1000))  
    {  
       process();  
    }  
 }  
   
   
 void  
124  UserAgent::addTransport(TransportType type, int port)  UserAgent::addTransport(TransportType type, int port)
125  {  {
126       for (; port < port+10; ++port)
127       {
128     try     try
129     {     {
130        if (port)        if (port)
# Line 130  Line 132 
132           if (!mNoV4)           if (!mNoV4)
133           {           {
134              mDum.addTransport(type, port, V4, Data::Empty, mTlsDomain);              mDum.addTransport(type, port, V4, Data::Empty, mTlsDomain);
135                   return;
136           }           }
137    
138           if (!mNoV6)           if (!mNoV6)
139           {           {
140              mDum.addTransport(type, port, V6, Data::Empty, mTlsDomain);              mDum.addTransport(type, port, V6, Data::Empty, mTlsDomain);
141                   return;
142           }           }
143        }        }
144     }     }
# Line 142  Line 146 
146     {     {
147        InfoLog (<< "Caught: " << e);        InfoLog (<< "Caught: " << e);
148        WarningLog (<< "Failed to add " << Tuple::toData(type) << " transport on " << port);        WarningLog (<< "Failed to add " << Tuple::toData(type) << " transport on " << port);
       throw;  
149     }     }
150         }
151       throw Transport::Exception("Port already in use", __FILE__, __LINE__);
152  }  }
153    
154    
# Line 307  Line 311 
311  int  int
312  UserAgent::onRequestRetry(ClientRegistrationHandle h, int retryMinimum, const SipMessage& msg)  UserAgent::onRequestRetry(ClientRegistrationHandle h, int retryMinimum, const SipMessage& msg)
313  {  {
314     assert(false);     //assert(false);
315     return -1;     return -1;
316  }  }
317    

Legend:
Removed from v.4078  
changed lines
  Added in v.4383

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27