/[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 2870 - (hide annotations) (download)
Sun May 30 17:28:44 2004 UTC (15 years, 7 months ago) by fluffy
Original Path: main/sip/resiprocate/dum/test/basicRegister.cxx
File size: 2431 byte(s)
bunch of registration stuf update
1 derek 2850 #include "resiprocate/dum/InviteSessionHandler.hxx"
2     #include "resiprocate/dum/DialogUsageManager.hxx"
3     #include "resiprocate/dum/RegistrationHandler.hxx"
4     #include "resiprocate/SipStack.hxx"
5     #include "resiprocate/dum/Profile.hxx"
6 alan 2861 #include "resiprocate/os/Log.hxx"
7 derek 2850
8     using namespace resip;
9    
10     class Client : public ClientRegistrationHandler
11     {
12     public:
13     Client() : done(false) {}
14    
15     virtual void onSuccess(ClientRegistration::Handle h, const SipMessage& response)
16     {
17     cerr << "Client::Success: " << response << endl;
18 alan 2857 sleep(5);
19 derek 2850 h->removeAll();
20     done = true;
21     }
22    
23     virtual void onFailure(ClientRegistration::Handle, const SipMessage& response)
24     {
25     cerr << "Client::Failure: " << response << endl;
26     }
27     bool done;
28     };
29    
30     /*
31     class RegistrationServer : public ServerRegistrationHandler
32     {
33     public:
34     RegistrationServer() : done(false) {}
35     virtual void onRefresh(ServerRegistration::Handle, const SipMessage& reg)=0;
36    
37     /// called when one of the contacts is removed
38     virtual void onRemoveOne(ServerRegistration::Handle, const SipMessage& reg)=0;
39    
40     /// Called when all the contacts are removed
41     virtual void onRemoveAll(ServerRegistration::Handle, const SipMessage& reg)=0;
42    
43     /// Called when a new contact is added. This is after authentication has
44     /// all sucseeded
45     virtual void onAdd(ServerRegistration::Handle, const SipMessage& reg)=0;
46    
47     /// Called when an registration expires
48     virtual void onExpired(ServerRegistration::Handle, const NameAddr& contact)=0;
49    
50     private:
51     bool done;
52     };
53     */
54    
55     int
56     main (int argc, char** argv)
57     {
58 fluffy 2870 Log::initialize(Log::COUT, Log::DEBUG, argv[0]);
59    
60 derek 2850 SipStack clientStack;
61     clientStack.addTransport(UDP, 5060);
62    
63     Client client;
64     Profile* p = new Profile;
65     DialogUsageManager clientDum(clientStack);
66     clientDum.setProfile(p);
67    
68     clientDum.setClientRegistrationHandler(&client);
69    
70     clientDum.getProfile()->setDefaultRegistrationTime(70);
71 alan 2861 SipMessage & regMessage = clientDum.makeRegistration(NameAddr("sip:502@jasomi.com"));
72 derek 2850 cerr << regMessage << "Generated register: " << endl << regMessage << endl;
73 fluffy 2870 clientDum.send( regMessage );
74    
75     while ( 1 )
76 derek 2850 {
77     FdSet fdset;
78 fluffy 2870
79     clientStack.buildFdSet(fdset);
80 derek 2850 int err = fdset.selectMilliSeconds(100);
81     assert ( err != -1 );
82 fluffy 2870 clientStack.process(fdset);
83 derek 2850 }
84     }

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27