139 if (bytes_received==0 || err)
141 if (err==ba::error::eof)
142 Warn(
"Connection to "+
URL()+
" closed by remote host (FAD).");
146 if (err && err!=ba::error::eof &&
147 err!=ba::error::basic_errors::not_connected &&
148 err!=ba::error::basic_errors::operation_aborted)
151 str <<
"Reading from " <<
URL() <<
": " << err.message() <<
" (" << err <<
")";
161 if (bytes_received!=
sizeof(FAD::EventHeader))
164 str <<
"Bytes received (" << bytes_received <<
" don't match header size " <<
sizeof(FAD::EventHeader);
175 str <<
"Invalid header received: start delimiter wrong, received ";
201 str <<
"Invalid data received: end delimiter wrong, received ";
208 uint8_t *ptr =
reinterpret_cast<uint8_t*
>(
fBuffer.data());
212 if (ptr+
sizeof(FAD::ChannelHeader) > end)
214 Error(
"Channel header exceeds buffer size.");
220 ptr += sizeof(
FAD::ChannelHeader);
226 Error(
"Data block exceeds buffer size.");
231 const uint16_t *
data =
reinterpret_cast<uint16_t*
>(ptr);
241 fBuffer.resize(
sizeof(FAD::EventHeader)/2);
void AsyncWait(boost::asio::deadline_timer &timer, int millisec, void(Connection::*handler)(const boost::system::error_code &))
virtual void UpdateChannelHeaders()
boost::asio::deadline_timer fInTimeout
void PostClose(bool restart=true)
virtual void UpdateFirstHeader()
void debugHead(const FAD::EventHeader &h)
FAD::ChannelHeader fChannelHeader[FAD::kNumChannels]
vector< uint16_t > fBuffer
int Error(const std::string &str)
int Warn(const std::string &str)
void AsyncRead(const boost::asio::mutable_buffers_1 buffers, int type=0)
virtual void HandleReadTimeout(const boost::system::error_code &)
virtual void UpdateEventHeader()
static EventBuilderWrapper * This
FAD::EventHeader fEventHeader
virtual void UpdateData(const uint16_t *data, size_t sz)