Handle completion of a read operation.
| 60 | |
| 61 | /// Handle completion of a read operation. |
| 62 | void handle_read(const boost::system::error_code& e) |
| 63 | { |
| 64 | if (!e) |
| 65 | { |
| 66 | // Print out the data that was received. |
| 67 | for (std::size_t i = 0; i < stocks_.size(); ++i) |
| 68 | { |
| 69 | std::cout << "Stock number " << i << "\n"; |
| 70 | std::cout << " code: " << stocks_[i].code << "\n"; |
| 71 | std::cout << " name: " << stocks_[i].name << "\n"; |
| 72 | std::cout << " open_price: " << stocks_[i].open_price << "\n"; |
| 73 | std::cout << " high_price: " << stocks_[i].high_price << "\n"; |
| 74 | std::cout << " low_price: " << stocks_[i].low_price << "\n"; |
| 75 | std::cout << " last_price: " << stocks_[i].last_price << "\n"; |
| 76 | std::cout << " buy_price: " << stocks_[i].buy_price << "\n"; |
| 77 | std::cout << " buy_quantity: " << stocks_[i].buy_quantity << "\n"; |
| 78 | std::cout << " sell_price: " << stocks_[i].sell_price << "\n"; |
| 79 | std::cout << " sell_quantity: " << stocks_[i].sell_quantity << "\n"; |
| 80 | } |
| 81 | } |
| 82 | else |
| 83 | { |
| 84 | // An error occurred. |
| 85 | std::cerr << e.message() << std::endl; |
| 86 | } |
| 87 | |
| 88 | // Since we are not starting a new operation the io_context will run out of |
| 89 | // work to do and the client will exit. |
| 90 | } |
| 91 | |
| 92 | private: |
| 93 | /// The connection to the server. |