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

Annotation of /main/resip/dum/test/basicRegister.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5948 - (hide annotations) (download)
Fri Feb 17 15:30:16 2006 UTC (13 years, 9 months ago) by dworley
File MIME type: text/plain
File size: 5977 byte(s)
Setting more svn: properties, and adding EOLs to the ends of files
that need it.

1 derek 5283 #include "resip/stack/SipStack.hxx"
2 jason 5276 #include "resip/dum/ClientAuthManager.hxx"
3     #include "resip/dum/ClientRegistration.hxx"
4     #include "resip/dum/DialogUsageManager.hxx"
5     #include "resip/dum/MasterProfile.hxx"
6     #include "resip/dum/RegistrationHandler.hxx"
7     #include "rutil/Log.hxx"
8     #include "rutil/Logger.hxx"
9     #include "rutil/Subsystem.hxx"
10     #include "resip/dum/KeepAliveManager.hxx"
11 derek 2850
12 daniel 4740 #ifdef WIN32
13 derek 5283 #include "resip/stack/WinSecurity.hxx"
14 daniel 4740 #endif
15 derek 2955
16 alan 2906 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST
17    
18 derek 2850 using namespace resip;
19 jason 4010 using namespace std;
20 derek 2850
21 daniel 4740 class ClientHandler : public ClientRegistrationHandler
22 derek 2955 {
23     public:
24 daniel 4740 ClientHandler() : done(false) {}
25 derek 2955
26 jason 2941 virtual void onSuccess(ClientRegistrationHandle h, const SipMessage& response)
27 derek 2850 {
28 daniel 4740 InfoLog( << "ClientHandler::onSuccess: " << endl );
29    
30     cerr << "Pausing before unregister" << endl;
31    
32 derek 2929 #ifdef WIN32
33 daniel 4740 Sleep(2000);
34 derek 2929 #else
35 daniel 4740 sleep(5);
36 derek 2929 #endif
37 daniel 4740 h->removeAll();
38 derek 2850 }
39    
40 sgodin 5758 virtual void onRemoved(ClientRegistrationHandle, const SipMessage& response)
41 sgodin 3458 {
42 daniel 4740 InfoLog ( << "ClientHandler::onRemoved ");
43     done = true;
44 sgodin 3458 }
45    
46 jason 2941 virtual void onFailure(ClientRegistrationHandle, const SipMessage& response)
47 derek 2850 {
48 daniel 4740 InfoLog ( << "ClientHandler::onFailure: " << response );
49 derek 2850 }
50 alan 2906
51 jason 4335 virtual int onRequestRetry(ClientRegistrationHandle, int retrySeconds, const SipMessage& response)
52     {
53 daniel 4740 InfoLog ( << "ClientHandler:onRequestRetry");
54     return -1;
55 jason 4335 }
56    
57 derek 2850 bool done;
58     };
59    
60    
61    
62     int
63     main (int argc, char** argv)
64     {
65 alan 2877
66 daniel 4740 if ( argc < 3 ) {
67     cout << "usage: " << argv[0] << " sip:user passwd\n";
68     return 0;
69     }
70 alan 2877
71 daniel 4740 Log::initialize(Log::Cout, Log::Stack, argv[0]);
72    
73     NameAddr userAor(argv[1]);
74     Data passwd(argv[2]);
75    
76 greg 4796 #ifdef USE_SSL
77 daniel 4740 #ifdef WIN32
78 greg 4796 Security* security = new WinSecurity;
79 daniel 4740 #else
80     Security* security = new Security;
81 greg 4796 #endif
82 daniel 4740 SipStack stack(security);
83     #else
84     SipStack stack;
85     #endif
86    
87     DialogUsageManager clientDum(stack);
88 sgodin 4781 SharedPtr<MasterProfile> profile(new MasterProfile);
89 jason 4010 auto_ptr<ClientAuthManager> clientAuth(new ClientAuthManager);
90 daniel 4740 ClientHandler clientHandler;
91 derek 2929
92 daniel 4740 clientDum.addTransport(UDP, 10000 + rand()&0x7fff, V4);
93     // clientDum.addTransport(UDP, 10000 + rand()&0x7fff, V6);
94     clientDum.addTransport(TCP, 10000 + rand()&0x7fff, V4);
95     // clientDum.addTransport(TCP, 10000 + rand()&0x7fff, V6);
96 greg 4796 #ifdef USE_SSL
97 daniel 4740 clientDum.addTransport(TLS, 10000 + rand()&0x7fff, V4);
98     // clientDum.addTransport(TLS, 10000 + rand()&0x7fff, V6);
99 greg 4796 #endif
100 sgodin 4781 clientDum.setMasterProfile(profile);
101 daniel 4740 clientDum.setClientRegistrationHandler(&clientHandler);
102 sgodin 3458 clientDum.setClientAuthManager(clientAuth);
103 jason 4010 clientDum.getMasterProfile()->setDefaultRegistrationTime(70);
104 derek 2991
105 daniel 4740 // keep alive test.
106     auto_ptr<KeepAliveManager> keepAlive(new KeepAliveManager);
107     clientDum.setKeepAliveManager(keepAlive);
108 alan 2877
109 daniel 4740 clientDum.getMasterProfile()->setDefaultFrom(userAor);
110 sgodin 4781 profile->setDigestCredential(userAor.uri().host(),
111 daniel 4740 userAor.uri().user(),
112     passwd);
113 derek 2991
114 sgodin 5758 SharedPtr<SipMessage> regMessage = clientDum.makeRegistration(userAor);
115 derek 2984 NameAddr contact;
116 alan 2877
117 fluffy 2870 clientDum.send( regMessage );
118 alan 2877
119     int n = 0;
120 daniel 4740 while ( !clientHandler.done )
121 derek 2850 {
122 jason 4335 FdSet fdset;
123 fluffy 2870
124 sgodin 4342 stack.buildFdSet(fdset);
125 jason 4335 int err = fdset.selectMilliSeconds(100);
126     assert ( err != -1 );
127 alan 2877
128 sgodin 4342 stack.process(fdset);
129     while(clientDum.process());
130    
131 daniel 4740 if (n == 1000) clientHandler.done = true;
132    
133 jason 4335 if (!(n++ % 10)) cerr << "|/-\\"[(n/10)%4] << '\b';
134 derek 2850 }
135 derek 2984 return 0;
136 derek 2850 }
137 derek 4602
138     /* ====================================================================
139     * The Vovida Software License, Version 1.0
140     *
141     * Copyright (c) 2000 Vovida Networks, Inc. All rights reserved.
142     *
143     * Redistribution and use in source and binary forms, with or without
144     * modification, are permitted provided that the following conditions
145     * are met:
146     *
147     * 1. Redistributions of source code must retain the above copyright
148     * notice, this list of conditions and the following disclaimer.
149     *
150     * 2. Redistributions in binary form must reproduce the above copyright
151     * notice, this list of conditions and the following disclaimer in
152     * the documentation and/or other materials provided with the
153     * distribution.
154     *
155     * 3. The names "VOCAL", "Vovida Open Communication Application Library",
156     * and "Vovida Open Communication Application Library (VOCAL)" must
157     * not be used to endorse or promote products derived from this
158     * software without prior written permission. For written
159     * permission, please contact vocal@vovida.org.
160     *
161     * 4. Products derived from this software may not be called "VOCAL", nor
162     * may "VOCAL" appear in their name, without prior written
163     * permission of Vovida Networks, Inc.
164     *
165     * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
166     * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
167     * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
168     * NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL VOVIDA
169     * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
170     * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
171     * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
172     * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
173     * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
174     * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
175     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
176     * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
177     * DAMAGE.
178     *
179     * ====================================================================
180     *
181     * This software consists of voluntary contributions made by Vovida
182     * Networks, Inc. and many individuals on behalf of Vovida Networks,
183     * Inc. For more information on Vovida Networks, Inc., please see
184     * <http://www.vovida.org/>.
185     *
186     */

Properties

Name Value
svn:eol-style native
svn:mime-type text/plain

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27