ASYNC - Prime context ready to read a message body
| 552 | |
| 553 | // ASYNC - Prime context ready to read a message body |
| 554 | void ReadBody() |
| 555 | { |
| 556 | // If this function is called, a header has already been read, and that header |
| 557 | // request we read a body, The space for that body has already been allocated |
| 558 | // in the temporary message object, so just wait for the bytes to arrive... |
| 559 | asio::async_read(m_socket, asio::buffer(m_msgTemporaryIn.body.data(), m_msgTemporaryIn.body.size()), |
| 560 | [this](std::error_code ec, std::size_t length) |
| 561 | { |
| 562 | if (!ec) |
| 563 | { |
| 564 | // ...and they have! The message is now complete, so add |
| 565 | // the whole message to incoming queue |
| 566 | AddToIncomingMessageQueue(); |
| 567 | } |
| 568 | else |
| 569 | { |
| 570 | // As above! |
| 571 | std::cout << "[" << id << "] Read Body Fail.\n"; |
| 572 | m_socket.close(); |
| 573 | } |
| 574 | }); |
| 575 | } |
| 576 | |
| 577 | // "Encrypt" data |
| 578 | uint64_t scramble(uint64_t nInput) |