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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2861 - (show annotations) (download)
Sun May 30 04:27:35 2004 UTC (15 years, 8 months ago) by alan
File size: 2631 byte(s)
minor tweaks for basicRegister (test)
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
59 Log::initialize(Log::COUT, Log::DEBUG, argv[0]);
60
61 SipStack clientStack;
62 clientStack.addTransport(UDP, 5060);
63
64 Client client;
65 Profile* p = new Profile;
66 DialogUsageManager clientDum(clientStack);
67 clientDum.setProfile(p);
68
69 clientDum.setClientRegistrationHandler(&client);
70
71 clientDum.getProfile()->setDefaultRegistrationTime(70);
72 SipMessage & regMessage = clientDum.makeRegistration(NameAddr("sip:502@jasomi.com"));
73 cerr << regMessage << "Generated register: " << endl << regMessage << endl;
74
75 #if 0
76 while ( (!client.done)
77 {
78 FdSet fdset;
79 // Should these be buildFdSet on the DUM?
80 stackA.buildFdSet(fdset);
81 stackB.buildFdSet(fdset);
82 int err = fdset.selectMilliSeconds(100);
83 assert ( err != -1 );
84 stackA.process(fdset);
85 stackB.process(fdset);
86
87 if (bHangupAt!=0)
88 {
89 if (time(NULL)>bHangUpAt)
90 {
91 handlerB.hangup();
92 }
93 }
94 }
95 #endif
96
97 }

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27