Project

General

Profile

Revision 453

fixed compile errors in colonetserver

View differences:

ColonetServer.cpp
38 38
 */
39 39
ColonetServer::ColonetServer() {
40 40
  listen_socket = 0;
41
  connection_pool = new ConnectionPool(this);
41 42
}
42 43

  
43 44
/**
44 45
 * @brief Destructor for ColonetServer
45 46
 */
46 47
ColonetServer::~ColonetServer() {
48
  delete connection_pool;
47 49
}
48 50

  
49 51
/**
......
94 96
 * @brief Starts the server running (starts an infinite loop)
95 97
 */
96 98
int ColonetServer::run_server() {
97
  connection_pool.add_new_socket_to_pool(listen_socket);
99
  connection_pool->add_new_socket_to_pool(listen_socket);
98 100

  
99 101
  int accept_socket = 0;
100 102
  struct sockaddr_in client_addr;
......
105 107
  }
106 108

  
107 109
  while(1) {
110
    connection_pool->perform_select(listen_socket);
108 111

  
109
    connection_pool.perform_select(listen_socket);
110

  
111 112
    //either no descriptors are ready or there was an error
112
    if (connection_pool.get_number_clients_ready() <= 0) {
113
    if (connection_pool->get_number_clients_ready() <= 0) {
113 114
      continue;
114 115
    }
115 116

  
116
    if (connection_pool.is_socket_ready_to_read(listen_socket)) {
117
    if (connection_pool->is_socket_ready_to_read(listen_socket)) {
117 118
      printf("Something is trying to connect...\n");
118 119
      if ((accept_socket = accept(listen_socket, (struct sockaddr*) &client_addr, &client_addr_size)) < 0) {
119 120
        if (errno == EMFILE) {
......
133 134
        logger->log_string(LOG_TYPE_CONNECT, log_buffer);
134 135
      }
135 136

  
136
      if (connection_pool.add_client(accept_socket) < 0) {
137
      if (connection_pool->add_client(accept_socket) < 0) {
137 138
        printf("\tThere was an error when trying to add a client to the connection pool.");
138 139
        continue;
139 140
      }
......
146 147
      }
147 148
    }
148 149

  
149
    if (connection_pool.check_clients() < 0) {
150
    if (connection_pool->check_clients() < 0) {
150 151
      printf("\tThere was an error trying to update the clients.");
151 152
      continue;
152 153
    }
......
162 163
* @param len - Length of the data param.
163 164
*/
164 165
int ColonetServer::process_received_wireless_message(int dest, char* data, int len) {
165
  if (connection_pool.write_to_client(dest, data, len) == ERROR_INVALID_CLIENT_ID) {
166
  if (connection_pool->write_to_client(dest, data, len) == ERROR_INVALID_CLIENT_ID) {
166 167
    printf("The robot wanted to pass the data to a client not in the pool.\n");
167 168
    return -1;
168 169
  }

Also available in: Unified diff