void Server::HandleReceive() { if(mCommand->IsValid()) { if(mCommand->IsConnectionRequest()) { // let the client know we're good to go by echoing received data ServerQuickResponseCode reply(mCommand->GetData().front()); SendData(&reply); } else { mCommand->DecodeDataToCommand(); for(auto& callback : mCallbacks) callback(mCommand.get(), this); } } mCommand->ClearData(); if(mStopServer) mServerRunning = false; else StartReceive(); }
void I2CDevice::StartCommunication() { if (!m_status) { std::cout << "Init device fail: " << std::endl; return; } StartWrite(); StartReceive(); m_ioService.run(); }
void Server::Start() { if(mServerRunning) return; mServerRunning = true; mStopServer = false; StartReceive(); mIOService.run(); }
void I2CDevice::HandleRead(const boost::system::error_code& ex, std::size_t length) { if (ex) { std::cout << "Handle read fail: " << ex.message() << std::endl; m_ioService.stop(); return; } // The actual number of bytes received is committed to the buffer so that we // can extract it using a std::istream object. m_replyBuffer.commit(length); // Decode the reply packet. std::istream is(&m_replyBuffer); std:: cout << "We get next message: " << std::endl; std::copy(std::istream_iterator<char>(is), std::istream_iterator<char>(), std::ostream_iterator<char>(std::cout)); StartReceive(); }
// --------------------------------------------------------------------------- // Second phase construction. // --------------------------------------------------------------------------- // void CIkev1Receiver::ConstructL() { StartReceive(); }