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

Last change on this file since 11189 was 11071, checked in by tbretz, 13 years ago
Replaced v19r21 by a version extracted with 'unzip -a' to get proper unix text format.
File size: 1.8 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 }
42public :
43 StrService() : DimInfo("TEST/STRVAL","not available") {};
44};
45
46int main()
47{
48
49 ErrorHandler errHandler;
50 StrService servstr;
51 char *server, *ptr, *ptr1;
52 DimBrowser br;
53 int type, n, pid;
54
55// DimClient::addErrorHandler(errHandler);
56
57 n = br.getServices("*");
58 cout << "found " << n << " services" << endl;
59
60 while((type = br.getNextService(ptr, ptr1))!= 0)
61 {
62 cout << "type = " << type << " - " << ptr << " " << ptr1 << endl;
63 }
64
65 br.getServers();
66 while(br.getNextServer(server, ptr1, pid))
67 {
68 cout << server << " @ " << ptr1 << ", pid = " << pid << endl;
69 }
70
71 br.getServerClients("DIS_DNS");
72 while(br.getNextServerClient(ptr, ptr1))
73 {
74 cout << ptr << " @ " << ptr1 << endl;
75 }
76
77 DimInfo servint("TEST/INTVAL",-1);
78
79 while(1)
80 {
81 sleep(10);
82
83 cout << "Current INTVAL : " << servint.getInt() << endl;
84 DimClient::sendCommand("TEST/CMND","UPDATE_STRVAL");
85 }
86 return 0;
87}
Note: See TracBrowser for help on using the repository browser.