FACT++  1.0
void ConnectionGPS::HandleRead ( const boost::system::error_code &  err,
size_t  bytes_received 
)
inlineprivate

Definition at line 173 of file gpsctrl.cc.

References buffer, Error(), and str.

Referenced by StartReadReport().

174  {
175  // Do not schedule a new read if the connection failed.
176  if (bytes_received==0 || err)
177  {
178  if (err==ba::error::eof)
179  Warn("Connection closed by remote host.");
180 
181  // 107: Transport endpoint is not connected (bs::error_code(107, bs::system_category))
182  // 125: Operation canceled
183  if (err && err!=ba::error::eof && // Connection closed by remote host
184  err!=ba::error::basic_errors::not_connected && // Connection closed by remote host
185  err!=ba::error::basic_errors::operation_aborted) // Connection closed by us
186  {
187  ostringstream str;
188  str << "Reading from " << URL() << ": " << err.message() << " (" << err << ")";// << endl;
189  Error(str);
190  }
191  PostClose(err!=ba::error::basic_errors::operation_aborted);
192  return;
193  }
194 
195  istream is(&fBuffer);
196 
197  string buffer;
198  if (!getline(is, buffer, '\n'))
199  {
200  Error("Received message does not contain \\n... closing connection.");
201  PostClose(false);
202  return;
203  }
204  buffer = buffer.substr(0, buffer.size()-1);
205 
206  if (fIsVerbose)
207  Out() << buffer << endl;
208 
209  try
210  {
211  if (!ParseAnswer(buffer))
212  {
213  Error("Received: "+buffer);
214  PostClose(false);
215  return;
216  }
217  }
218  catch (const exception &e)
219  {
220  Error("Parsing NEMA message failed ["+string(e.what())+"]");
221  Error("Received: "+buffer);
222  PostClose(false);
223  return;
224  }
225 
226  fLastReport = Time();
227  StartReadReport();
228  }
Time fLastReport
Definition: gpsctrl.cc:31
bool fIsVerbose
Definition: gpsctrl.cc:29
boost::asio::streambuf fBuffer
Definition: gpsctrl.cc:230
Adds some functionality to boost::posix_time::ptime for our needs.
Definition: Time.h:30
char str[80]
Definition: test_client.c:7
bool ParseAnswer(const string &buffer)
Definition: gpsctrl.cc:58
int buffer[BUFFSIZE]
Definition: db_dim_client.c:14
void StartReadReport()
Definition: gpsctrl.cc:232
Error()
Definition: HeadersFTM.h:197

+ Here is the call graph for this function:

+ Here is the caller graph for this function: