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

Annotation of /main/sip/resiprocate/dum/test/basicRegister.cxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2857 - (hide annotations) (download)
Sun May 30 03:46:09 2004 UTC (15 years, 8 months ago) by alan
File size: 2539 byte(s)
hash repairs
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    
7     using namespace resip;
8    
9     class Client : public ClientRegistrationHandler
10     {
11     public:
12     Client() : done(false) {}
13    
14     virtual void onSuccess(ClientRegistration::Handle h, const SipMessage& response)
15     {
16     cerr << "Client::Success: " << response << endl;
17 alan 2857 sleep(5);
18 derek 2850 h->removeAll();
19     done = true;
20     }
21    
22     virtual void onFailure(ClientRegistration::Handle, const SipMessage& response)
23     {
24     cerr << "Client::Failure: " << response << endl;
25     }
26     bool done;
27     };
28    
29     /*
30     class RegistrationServer : public ServerRegistrationHandler
31     {
32     public:
33     RegistrationServer() : done(false) {}
34     virtual void onRefresh(ServerRegistration::Handle, const SipMessage& reg)=0;
35    
36     /// called when one of the contacts is removed
37     virtual void onRemoveOne(ServerRegistration::Handle, const SipMessage& reg)=0;
38    
39     /// Called when all the contacts are removed
40     virtual void onRemoveAll(ServerRegistration::Handle, const SipMessage& reg)=0;
41    
42     /// Called when a new contact is added. This is after authentication has
43     /// all sucseeded
44     virtual void onAdd(ServerRegistration::Handle, const SipMessage& reg)=0;
45    
46     /// Called when an registration expires
47     virtual void onExpired(ServerRegistration::Handle, const NameAddr& contact)=0;
48    
49     private:
50     bool done;
51     };
52     */
53    
54     int
55     main (int argc, char** argv)
56     {
57    
58     SipStack clientStack;
59     clientStack.addTransport(UDP, 5060);
60    
61     Client client;
62     Profile* p = new Profile;
63     DialogUsageManager clientDum(clientStack);
64     clientDum.setProfile(p);
65    
66     clientDum.setClientRegistrationHandler(&client);
67    
68     clientDum.getProfile()->setDefaultRegistrationTime(70);
69     SipMessage & regMessage = clientDum.makeRegistration(NameAddr("502@jasomi.com"));
70     cerr << regMessage << "Generated register: " << endl << regMessage << endl;
71    
72     #if 0
73     while ( (!client.done)
74     {
75     FdSet fdset;
76     // Should these be buildFdSet on the DUM?
77     stackA.buildFdSet(fdset);
78     stackB.buildFdSet(fdset);
79     int err = fdset.selectMilliSeconds(100);
80     assert ( err != -1 );
81     stackA.process(fdset);
82     stackB.process(fdset);
83    
84     if (bHangupAt!=0)
85     {
86     if (time(NULL)>bHangUpAt)
87     {
88     handlerB.hangup();
89     }
90     }
91     }
92     #endif
93    
94     }

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27