/[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 2894 - (show annotations) (download)
Sun May 30 22:16:35 2004 UTC (15 years, 8 months ago) by jason
Original Path: main/sip/resiprocate/dum/test/basicRegister.cxx
File size: 2784 byte(s)
use long instead of UInt64 for hash


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
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 sleep(5);
19 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 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 SipStack clientStack;
64 clientStack.addTransport(UDP, 15060);
65 NameAddr aor("sip:502@jasomi.com");
66
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 clientDum.getProfile()->setDefaultAor(aor);
74
75 #if 0
76 p->addDigestCredential( "sip.jasomi.com", "502", "resiprocate" );
77 #endif
78
79 SipMessage & regMessage = clientDum.makeRegistration(aor);
80
81 cerr << regMessage << "Generated register: " << endl << regMessage << endl;
82 clientDum.send( regMessage );
83
84 int n = 0;
85 while ( !client.done )
86
87 {
88 FdSet fdset;
89
90 // Should these be buildFdSet on the DUM?
91 clientStack.buildFdSet(fdset);
92 int err = fdset.selectMilliSeconds(100);
93 assert ( err != -1 );
94
95 clientDum.process(fdset);
96 if (!(n++ % 10)) cerr << "|/-\\"[(n/10)%4] << '\b';
97
98 }
99
100 }

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27