FACT++  1.0
test_client.cxx
Go to the documentation of this file.
1 #include <iostream>
2 #include <dic.hxx>
3 using namespace std;
4 
5 class 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  }
21 public:
23 };
24 
25 class 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  }
46 public :
47  StrService() : DimInfo("TEST/STRVAL",(char *)"not available") {};
48 };
49 
50 int 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 
93  }
94  return 0;
95 }
int getServerClients(const char *serverName)
Definition: diccpp.cxx:927
static int sendCommand(const char *name, int data)
Definition: diccpp.cxx:1098
int getNextServerClient(char *&client, char *&node)
Definition: diccpp.cxx:1067
int getInt()
Definition: dic.hxx:103
int getServices(const char *serviceName)
Definition: diccpp.cxx:849
STL namespace.
Definition: dic.hxx:31
static int inCallback()
Definition: diccpp.cxx:1358
int main()
Definition: test_client.cxx:50
int type
void addErrorHandler()
Definition: diccpp.cxx:1272
int getServers()
Definition: diccpp.cxx:874
static char * getServerName()
Definition: diccpp.cxx:1296
void infoHandler()
Definition: test_client.cxx:28
int getNextServer(char *&server, char *&node)
Definition: diccpp.cxx:982
static char ** getServerServices()
Definition: diccpp.cxx:1319
int getNextService(char *&service, char *&format)
Definition: diccpp.cxx:948
void errorHandler(int severity, int code, char *msg)
Definition: test_client.cxx:7