| 21 | } |
| 22 | |
| 23 | void OnRecv(const Handle& handle, base::CBuffer* data, uint32_t len, uint32_t err) { |
| 24 | if (err != CEC_SUCCESS) { |
| 25 | std::cout << "something error while read." << std::endl; |
| 26 | return; |
| 27 | } |
| 28 | |
| 29 | char ret_char[4] = {0}; |
| 30 | if (data->GetCanReadLength() >= 2) { |
| 31 | data->Read(ret_char, 4); |
| 32 | |
| 33 | } else { |
| 34 | return; |
| 35 | } |
| 36 | std::string ret(ret_char); |
| 37 | std::cout << "recv from server : " << ret << std::endl; |
| 38 | |
| 39 | if (_status == hello) { |
| 40 | if (ret == "OK") { |
| 41 | std::cout << "start to send file ..." << std::endl; |
| 42 | _status = sending; |
| 43 | Send(handle); |
| 44 | |
| 45 | } else { |
| 46 | std::cout << "server refuse recv the file!" << std::endl; |
| 47 | } |
| 48 | |
| 49 | } else if (_status == sending) { |
| 50 | if (ret == "OK") { |
| 51 | std::cout << "send file success!" << std::endl; |
| 52 | |
| 53 | } else { |
| 54 | std::cout << "something error while sending!" << std::endl; |
| 55 | } |
| 56 | |
| 57 | handle->Close(); |
| 58 | delete _net; |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | void OnConnect(const Handle& handle, uint32_t err) { |
| 63 | if (err == CEC_SUCCESS) { |
nothing calls this directly
no test coverage detected