1 |
ab11 |
1.1 |
#include <iostream> |
2 |
|
|
#include <string> |
3 |
|
|
#include <unistd.h> // linux header for the sleep function |
4 |
|
|
#include "SmallNet.h" |
5 |
|
|
|
6 |
|
|
using std::string; |
7 |
|
|
|
8 |
|
|
class Config { |
9 |
|
|
|
10 |
|
|
public: |
11 |
|
|
// public methods |
12 |
|
|
Config( string serverName, int serverPort ); |
13 |
|
|
int getUDPFilterPort(){ return UDPFilterPort; }; // inline function |
14 |
|
|
string getUDPFilterName(){ return UDPFilterName; }; // inline |
15 |
|
|
int getProperty( string propertyName ); |
16 |
|
|
|
17 |
|
|
// public variables |
18 |
|
|
|
19 |
|
|
private: |
20 |
|
|
// private methods |
21 |
|
|
int loadConfig(); // do the chat dialog |
22 |
|
|
int establishHeartbeat(); // tell smallnet to make a connection |
23 |
|
|
int chatHeartbeat(); // send the relevant commands to the heartbeat |
24 |
|
|
int destroyHeartbeat(); // tell smallnet to close a connection |
25 |
|
|
int establishConfig(); // tell smallnet to make a connection to the config manager |
26 |
|
|
int chatConfig(); // send the relevant commands to get the config |
27 |
|
|
int destroyConfig(); // tell smallnet to close the connection to the config manager |
28 |
|
|
|
29 |
|
|
|
30 |
|
|
// private (global) variables |
31 |
|
|
int configConnectionRetryTime; // how long to wait before retrying a connection to the |
32 |
|
|
// config manager if a connection cannot be established |
33 |
|
|
string configName; // the name of the server which will return our config |
34 |
|
|
int configPort; // the port on the server which will return our config |
35 |
|
|
int UDPFilterPort; // the port number of our assigned filter |
36 |
|
|
string UDPFilterName; // the name of our assigned filter |
37 |
|
|
int TCPFilterPort; // the tcp port for heartbeats |
38 |
|
|
bool configChanged; // has the config changed since we last loaded it? |
39 |
|
|
string lastModified; // saves the last modifed long integer |
40 |
|
|
string fileList; // saves the last modifed file list |
41 |
|
|
int numProperties; // the number of properties which this host wants |
42 |
|
|
string propertyNames[20]; // an array of strings which corrisponds to... |
43 |
|
|
string propertyValues[20]; // these values |
44 |
|
|
SmallNet net; // interface onto SmallNet |
45 |
|
|
|
46 |
|
|
|
47 |
|
|
|
48 |
|
|
}; // class Config |