Definition at line 123 of file ServerConnector.h. References Connect(), Impala::Application::Videolympics::GlobalStats::connected, ILOG_DEBUG, ILOG_ERROR, mConnected, mGlobalStats, mSocket, mStats, ParsePoll(), ParseStat(), CommunicatingSocket::recv(), and CommunicatingSocket::send(). Referenced by Impala::Application::Videolympics::Vidolvi::Debug(), and Impala::Application::Videolympics::VidolviWindow::DisplayFunc(). 00124 { 00125 Connect(); 00126 if (!mConnected) 00127 return false; 00128 00129 ILOG_DEBUG("Requesting POLL update..."); 00130 try { 00131 mSocket->send("POLL", 4); 00132 } catch (SocketException e) { 00133 ILOG_ERROR("Server connection failed during SEND."); 00134 mConnected = false; 00135 mGlobalStats->connected = false; 00136 mStats.clear(); 00137 return false; 00138 } 00139 // ILOG_DEBUG("receiving length..."); 00140 int aantal; 00141 try { 00142 mSocket->recv(&aantal, 4); 00143 } catch (SocketException e) { 00144 ILOG_ERROR("Server connection failed during RECV."); 00145 mConnected = false; 00146 mGlobalStats->connected = false; 00147 mStats.clear(); 00148 return false; 00149 } 00150 ILOG_DEBUG(aantal << " shots in queue"); 00151 char buffer[20000]; 00152 if (aantal > 0) 00153 { 00154 int recv = 0; 00155 try { 00156 recv = mSocket->recv(buffer, 20000); 00157 } catch (SocketException e) { 00158 ILOG_ERROR("Server connection failed during RECV."); 00159 mConnected = false; 00160 mGlobalStats->connected = false; 00161 mStats.clear(); 00162 return false; 00163 } 00164 if (recv <= 0) 00165 { 00166 ILOG_ERROR("There should be a queue, however nothing was read."); 00167 return false; 00168 } 00169 buffer[recv] = 0; 00170 ParsePoll(buffer); 00171 } 00172 00173 ILOG_DEBUG("Requesting POLL update..."); 00174 try { 00175 mSocket->send("STAT", 4); 00176 } catch (SocketException e) { 00177 ILOG_ERROR("Server connection failed."); 00178 mConnected = false; 00179 mGlobalStats->connected = false; 00180 mStats.clear(); 00181 return false; 00182 } 00183 try { 00184 mSocket->recv(&aantal, 4); 00185 } catch (SocketException e) { 00186 ILOG_ERROR("Server connection failed during RECV."); 00187 mConnected = false; 00188 mGlobalStats->connected = false; 00189 mStats.clear(); 00190 return false; 00191 } 00192 ILOG_DEBUG(aantal << " statistics received."); 00193 if (aantal > 0) 00194 { 00195 int recv; 00196 try { 00197 recv = mSocket->recv(buffer, 20000); 00198 } catch (SocketException e) { 00199 ILOG_ERROR("Server connection failed during RECV."); 00200 mConnected = false; 00201 mGlobalStats->connected = false; 00202 mStats.clear(); 00203 return false; 00204 } 00205 if (recv <= 0) 00206 { 00207 ILOG_ERROR("There should be statistics, however nothing was read."); 00208 return false; 00209 } 00210 buffer[recv] = 0; 00211 ParseStat(buffer, aantal); 00212 } 00213 00214 return true; 00215 }
Here is the call graph for this function:
|