/[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 2877 - (hide annotations) (download)
Sun May 30 19:03:55 2004 UTC (15 years, 7 months ago) by alan
Original Path: main/sip/resiprocate/dum/test/basicRegister.cxx
File size: 2700 byte(s)
adding REGISTER workflow
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 alan 2877 int level=(int)Log::DEBUG;
59     if (argc >1 ) level = atoi(argv[1]);
60    
61     Log::initialize(Log::COUT, (resip::Log::Level)level, argv[0]);
62    
63 derek 2850 SipStack clientStack;
64     clientStack.addTransport(UDP, 5060);
65 alan 2877 NameAddr aor("sip:502@jasomi.com");
66 derek 2850
67     Client client;
68     Profile* p = new Profile;
69     DialogUsageManager clientDum(clientStack);
70     clientDum.setProfile(p);
71     clientDum.setClientRegistrationHandler(&client);
72     clientDum.getProfile()->setDefaultRegistrationTime(70);
73 alan 2877 clientDum.getProfile()->setDefaultAor(aor);
74    
75     SipMessage & regMessage = clientDum.makeRegistration(aor);
76    
77 derek 2850 cerr << regMessage << "Generated register: " << endl << regMessage << endl;
78 fluffy 2870 clientDum.send( regMessage );
79 alan 2877
80     int n = 0;
81     while ( !client.done )
82    
83 derek 2850 {
84     FdSet fdset;
85 fluffy 2870
86 alan 2877 // Should these be buildFdSet on the DUM?
87 fluffy 2870 clientStack.buildFdSet(fdset);
88 derek 2850 int err = fdset.selectMilliSeconds(100);
89     assert ( err != -1 );
90 alan 2877
91     clientDum.process(fdset);
92     if (!(n++ % 10)) cerr << "|/-\\"[(n/10)%4] << '\b';
93    
94 derek 2850 }
95 alan 2877
96 derek 2850 }

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27