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

Last change on this file since 14575 was 11881, checked in by tbretz, 13 years ago
Updated to DIM V19r24
File size: 2.1 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 char *format;
33// cout << "Dns Node = " << DimClient::getDnsNode() << endl;
34 format = getFormat();
35 cout << "Received STRVAL : " << getString() << "format = " << format << endl;
36 services = DimClient::getServerServices();
37 cout<< "from "<< DimClient::getServerName() << " services:" << endl;
38 while(services[index])
39 {
40 cout << services[index] << endl;
41 index++;
42 }
43 int inCallback = DimClient::inCallback();
44 cout << "infoHandler: In callback "<< inCallback << endl;
45 }
46public :
47 StrService() : DimInfo("TEST/STRVAL","not available") {};
48};
49
50int main()
51{
52
53 ErrorHandler errHandler;
54 StrService servstr;
55 char *server, *ptr, *ptr1;
56 DimBrowser br;
57 int type, n, pid;
58
59// DimClient::addErrorHandler(errHandler);
60
61 n = br.getServices("*");
62 cout << "found " << n << " services" << endl;
63
64 while((type = br.getNextService(ptr, ptr1))!= 0)
65 {
66 cout << "type = " << type << " - " << ptr << " " << ptr1 << endl;
67 }
68
69 br.getServers();
70 while(br.getNextServer(server, ptr1, pid))
71 {
72 cout << server << " @ " << ptr1 << ", pid = " << pid << endl;
73 }
74
75 br.getServerClients("DIS_DNS");
76 while(br.getNextServerClient(ptr, ptr1))
77 {
78 cout << ptr << " @ " << ptr1 << endl;
79 }
80
81 DimInfo servint("TEST/INTVAL",-1);
82
83 while(1)
84 {
85 sleep(10);
86
87 cout << "Current INTVAL : " << servint.getInt() << endl;
88 DimClient::sendCommand("TEST/CMND","UPDATE_STRVAL");
89 int inCallback = DimClient::inCallback();
90 cout << "main: In callback "<< inCallback << endl;
91
92 DimClient::addErrorHandler(0);
93 }
94 return 0;
95}
Note: See TracBrowser for help on using the repository browser.