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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2906 - (show annotations) (download)
Tue Jun 1 20:42:13 2004 UTC (15 years, 6 months ago) by alan
Original Path: main/sip/resiprocate/dum/test/basicRegister.cxx
File size: 2904 byte(s)
adding logging
1 #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 #include "resiprocate/os/Log.hxx"
7 #include "resiprocate/os/Logger.hxx"
8 #include "resiprocate/os/Subsystem.hxx"
9
10 #define RESIPROCATE_SUBSYSTEM Subsystem::TEST
11
12 using namespace resip;
13
14 class Client : public ClientRegistrationHandler
15 {
16 public:
17 Client() : done(false) {}
18
19 virtual void onSuccess(ClientRegistration::Handle h, const SipMessage& response)
20 {
21 InfoLog( << "Client::Success: " << endl << response );
22 sleep(5);
23 h->removeAll();
24 done = true;
25 }
26
27 virtual void onFailure(ClientRegistration::Handle, const SipMessage& response)
28 {
29 InfoLog ( << "Client::Failure: " << response );
30 }
31
32 bool done;
33 };
34
35 /*
36 class RegistrationServer : public ServerRegistrationHandler
37 {
38 public:
39 RegistrationServer() : done(false) {}
40 virtual void onRefresh(ServerRegistration::Handle, const SipMessage& reg)=0;
41
42 /// called when one of the contacts is removed
43 virtual void onRemoveOne(ServerRegistration::Handle, const SipMessage& reg)=0;
44
45 /// Called when all the contacts are removed
46 virtual void onRemoveAll(ServerRegistration::Handle, const SipMessage& reg)=0;
47
48 /// Called when a new contact is added. This is after authentication has
49 /// all sucseeded
50 virtual void onAdd(ServerRegistration::Handle, const SipMessage& reg)=0;
51
52 /// Called when an registration expires
53 virtual void onExpired(ServerRegistration::Handle, const NameAddr& contact)=0;
54
55 private:
56 bool done;
57 };
58 */
59
60 int
61 main (int argc, char** argv)
62 {
63 int level=(int)Log::DEBUG;
64 if (argc >1 ) level = atoi(argv[1]);
65
66 Log::initialize(Log::COUT, (resip::Log::Level)level, argv[0]);
67
68 SipStack clientStack;
69 clientStack.addTransport(UDP, 15060);
70 NameAddr aor("sip:502@jasomi.com");
71
72 Client client;
73 Profile* p = new Profile;
74 DialogUsageManager clientDum(clientStack);
75 clientDum.setProfile(p);
76
77 clientDum.setClientRegistrationHandler(&client);
78 clientDum.getProfile()->setDefaultRegistrationTime(70);
79 clientDum.getProfile()->setDefaultAor(aor);
80
81 p->addDigestCredential( "sip.jasomi.com", "502", "resiprocate" );
82
83
84 SipMessage & regMessage = clientDum.makeRegistration(aor);
85
86 InfoLog( << regMessage << "Generated register: " << endl << regMessage );
87 clientDum.send( regMessage );
88
89 int n = 0;
90 while ( !client.done )
91
92 {
93 FdSet fdset;
94
95 // Should these be buildFdSet on the DUM?
96 clientStack.buildFdSet(fdset);
97 int err = fdset.selectMilliSeconds(100);
98 assert ( err != -1 );
99
100 clientDum.process(fdset);
101 if (!(n++ % 10)) cerr << "|/-\\"[(n/10)%4] << '\b';
102
103 }
104
105 }

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27