source: trunk/FACT++/dim/src/examples/test_client.cxx@ 11700

Last change on this file since 11700 was 11695, checked in by tbretz, 14 years ago
Updated from dim_v19r22 to dim_v19r23
File size: 2.0 KB
Line 
1#include <iostream>
2#include <dic.hxx>
3using namespace std;
4
5class ErrorHandler : public DimErrorHandler
6{
7 void errorHandler(int severity, int code, char *msg)
8 {
9 int index = 0;
10 char **services;
11 if(code){}
12 cout << severity << " " << msg << endl;
13 services = DimClient::getServerServices();
14 cout<< "from "<< DimClient::getServerName() << " services:" << endl;
15 while(services[index])
16 {
17 cout << services[index] << endl;
18 index++;
19 }
20 }
21public:
22 ErrorHandler() {DimClient::addErrorHandler(this);}
23};
24
25class StrService : public DimInfo
26{
27
28 void infoHandler()
29 {
30 int index = 0;
31 char **services;
32// cout << "Dns Node = " << DimClient::getDnsNode() << endl;
33 cout << "Received STRVAL : " << getString() << endl;
34 services = DimClient::getServerServices();
35 cout<< "from "<< DimClient::getServerName() << " services:" << endl;
36 while(services[index])
37 {
38 cout << services[index] << endl;
39 index++;
40 }
41 int inCallback = DimClient::inCallback();
42 cout << "infoHandler: In callback "<< inCallback << endl;
43 }
44public :
45 StrService() : DimInfo("TEST/STRVAL","not available") {};
46};
47
48int main()
49{
50
51 ErrorHandler errHandler;
52 StrService servstr;
53 char *server, *ptr, *ptr1;
54 DimBrowser br;
55 int type, n, pid;
56
57// DimClient::addErrorHandler(errHandler);
58
59 n = br.getServices("*");
60 cout << "found " << n << " services" << endl;
61
62 while((type = br.getNextService(ptr, ptr1))!= 0)
63 {
64 cout << "type = " << type << " - " << ptr << " " << ptr1 << endl;
65 }
66
67 br.getServers();
68 while(br.getNextServer(server, ptr1, pid))
69 {
70 cout << server << " @ " << ptr1 << ", pid = " << pid << endl;
71 }
72
73 br.getServerClients("DIS_DNS");
74 while(br.getNextServerClient(ptr, ptr1))
75 {
76 cout << ptr << " @ " << ptr1 << endl;
77 }
78
79 DimInfo servint("TEST/INTVAL",-1);
80
81 while(1)
82 {
83 sleep(10);
84
85 cout << "Current INTVAL : " << servint.getInt() << endl;
86 DimClient::sendCommand("TEST/CMND","UPDATE_STRVAL");
87 int inCallback = DimClient::inCallback();
88 cout << "main: In callback "<< inCallback << endl;
89
90 DimClient::addErrorHandler(0);
91 }
92 return 0;
93}
Note: See TracBrowser for help on using the repository browser.