Revision 22
moved around some more code
ColonetServer.cpp | ||
---|---|---|
27 | 27 |
#define LOG_BUFFER_LENGTH 128 |
28 | 28 |
|
29 | 29 |
ConnectionPool * connection_pool; |
30 |
ColonetWireless* wireless; |
|
30 | 31 |
|
31 | 32 |
ColonetServer::ColonetServer(): logger("logFile.txt") { |
32 | 33 |
} |
... | ... | |
42 | 43 |
if (initConnection(optionsG.listen_port) < 0) |
43 | 44 |
return -1; |
44 | 45 |
|
45 |
if (initWireless() < 0) {
|
|
46 |
if (initialize_wireless() < 0) {
|
|
46 | 47 |
fprintf(stderr, "%s: initWireless failed\n", __FUNCTION__); |
47 | 48 |
return -1; |
48 | 49 |
} |
... | ... | |
50 | 51 |
return 0; |
51 | 52 |
} |
52 | 53 |
|
54 |
int ColonetServer::initialize_wireless() |
|
55 |
{ |
|
56 |
char* log_filename = NULL; |
|
57 |
|
|
58 |
if (optionsG.logging_enabled) { |
|
59 |
log_filename = optionsG.log_filename; |
|
60 |
} |
|
61 |
|
|
62 |
wireless = new ColonetWireless(optionsG.wireless_port, |
|
63 |
wirelessMessageHandler, log_filename, |
|
64 |
/*!optionsG.listener_mode*/false, true); |
|
65 |
//Note: last arg set to true ignores token ring; in general, this should |
|
66 |
//probably be false (changed for demo purposes) |
|
67 |
|
|
68 |
if (!wireless->run_listener_thread()) { |
|
69 |
return -1; |
|
70 |
} |
|
71 |
|
|
72 |
return 0; |
|
73 |
} |
|
74 |
|
|
53 | 75 |
int ColonetServer::log_error(char * error_message) { |
54 | 76 |
return logger.logMessage(LOG_TYPE_ERROR, error_message); |
55 | 77 |
} |
... | ... | |
145 | 167 |
|
146 | 168 |
} |
147 | 169 |
|
148 |
if (connection_pool.check_clients() < 0) { |
|
170 |
if (connection_pool.check_clients(wireless) < 0) {
|
|
149 | 171 |
printf("\tThere was an error trying to update the clients."); |
150 | 172 |
continue; |
151 | 173 |
} |
... | ... | |
158 | 180 |
ConnectionPool * ColonetServer::get_connection_pool_pointer() { |
159 | 181 |
return &connection_pool; |
160 | 182 |
} |
183 |
|
|
184 |
|
Also available in: Unified diff