FACT++  1.0
void ConnectionGCN::HandleReceivedData ( const bs::error_code &  err,
size_t  bytes_received,
int  type 
)
inlineprivate

Definition at line 277 of file gcn.cc.

References buffer, Error(), and str.

Referenced by StartRead().

278  {
279  // Do not schedule a new read if the connection failed.
280  if (bytes_received==0 || err)
281  {
282  if (err==ba::error::eof)
283  Warn("Connection closed by remote host (GCN).");
284 
285  // 107: Transport endpoint is not connected (bs::error_code(107, bs::system_category))
286  // 125: Operation canceled
287  if (err && err!=ba::error::eof && // Connection closed by remote host
288  err!=ba::error::basic_errors::not_connected && // Connection closed by remote host
289  err!=ba::error::basic_errors::operation_aborted) // Connection closed by us
290  {
291  ostringstream str;
292  str << "Reading from " << URL() << ": " << err.message() << " (" << err << ")";// << endl;
293  Error(str);
294  }
295  PostClose(err!=ba::error::basic_errors::operation_aborted);
296  return;
297  }
298 
299  if (type==0)
300  {
301  fRxSize = ntohl(fRxSize);
302  fRxData.assign(fRxSize+1, 0);
303  ba::async_read(*this, ba::buffer(fRxData, fRxSize),
304  boost::bind(&ConnectionGCN::HandleReceivedData, this,
305  dummy::error, dummy::bytes_transferred, 1));
306  return;
307  }
308 
309  if (fDebugRx)
310  {
311  Out() << "------------------------------------------------------\n";
312  Out() << fRxData.data() << '\n';
313  Out() << "------------------------------------------------------" << endl;
314  }
315 
316  QDomDocument doc;
317  if (!doc.setContent(QString(fRxData.data()), false))
318  {
319  Warn("Parsing of xml failed [0].");
320  PostClose(false);
321  return;
322  }
323 
324  if (fDebugRx)
325  Out() << "Parsed:\n-------\n" << doc.toString().toStdString() << endl;
326 
327  const int rc = ProcessXml(doc.documentElement());
328  if (rc<0)
329  {
330  Warn("Parsing of xml failed [1].");
331  PostClose(false);
332  return;
333  }
334 
335  if (!rc)
336  {
337  Out() << "------------------------------------------------------\n";
338  Out() << doc.toString().toStdString() << '\n';
339  Out() << "------------------------------------------------------" << endl;
340  }
341 
342  StartRead();
343  }
char str[80]
Definition: test_client.c:7
uint32_t fRxSize
Definition: gcn.cc:41
void HandleReceivedData(const bs::error_code &err, size_t bytes_received, int type)
Definition: gcn.cc:277
int ProcessXml(const QDomElement &root)
Definition: gcn.cc:67
vector< char > fRxData
Definition: gcn.cc:42
bool fDebugRx
Definition: gcn.cc:39
int type
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
Error()
Definition: HeadersFTM.h:197
void StartRead()
Definition: gcn.cc:345

+ Here is the call graph for this function:

+ Here is the caller graph for this function: