| 22 | } |
| 23 | |
| 24 | void ReadFunc(const Handle& handle, base::CBuffer* data, uint32_t len, uint32_t error) { |
| 25 | if (error != CEC_CLOSED && error != CEC_CONNECT_BREAK) { |
| 26 | std::cout << " [ReadFunc]" << std::endl; |
| 27 | std::cout << *(data) << std::endl; |
| 28 | data->Clear(); |
| 29 | std::cout << " Thread ID : " << std::this_thread::get_id() << std::endl; |
| 30 | std::cout << " Read size : " << len << std::endl << std::endl; |
| 31 | base::CRunnable::Sleep(1000); |
| 32 | |
| 33 | if (index > 5) { |
| 34 | handle->Close(); |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | auto msg = GetMsg(); |
| 39 | handle->Write(msg.c_str(), msg.length()); |
| 40 | |
| 41 | } else { |
| 42 | std::cout << "Close" << std::endl; |
| 43 | } |
| 44 | } |
| 45 | |
| 46 | void ConnectFunc(const Handle& handle, uint32_t err) { |
| 47 | if (err == CEC_SUCCESS) { |