| 153 | } |
| 154 | |
| 155 | void TCPConnectionImpl::doRead() { |
| 156 | auto buffer = Valdi::makeShared<Buffer>(); |
| 157 | _socket.async_read_some( |
| 158 | boost::asio::buffer(buffer->data(), buffer->size()), |
| 159 | [buffer, strongSelf = strongSmallRef(this)](boost::system::error_code ec, std::size_t length) { |
| 160 | if (ec.failed()) { |
| 161 | strongSelf->close(errorFromBoostError(ec)); |
| 162 | } else { |
| 163 | { |
| 164 | std::lock_guard<Mutex> guard(strongSelf->_mutex); |
| 165 | if (strongSelf->_closed) { |
| 166 | return; |
| 167 | } |
| 168 | strongSelf->doRead(); |
| 169 | } |
| 170 | |
| 171 | auto listener = strongSelf->getDataListener(); |
| 172 | if (listener != nullptr) { |
| 173 | listener->onDataReceived(strongSelf, BytesView(buffer, buffer->data(), length)); |
| 174 | } |
| 175 | } |
| 176 | }); |
| 177 | } |
| 178 | |
| 179 | void TCPConnectionImpl::onReady() { |
| 180 | _address = resolveAddress(); |
nothing calls this directly
no test coverage detected