ASYNC - Send a message, connections are one-to-one so no need to specifiy the target, for a client, the target is the server and vice versa
| 413 | // ASYNC - Send a message, connections are one-to-one so no need to specifiy |
| 414 | // the target, for a client, the target is the server and vice versa |
| 415 | void Send(const message<T>& msg) |
| 416 | { |
| 417 | asio::post(m_asioContext, |
| 418 | [this, msg]() |
| 419 | { |
| 420 | // If the queue has a message in it, then we must |
| 421 | // assume that it is in the process of asynchronously being written. |
| 422 | // Either way add the message to the queue to be output. If no messages |
| 423 | // were available to be written, then start the process of writing the |
| 424 | // message at the front of the queue. |
| 425 | bool bWritingMessage = !m_qMessagesOut.empty(); |
| 426 | m_qMessagesOut.push_back(msg); |
| 427 | if (!bWritingMessage) |
| 428 | { |
| 429 | WriteHeader(); |
| 430 | } |
| 431 | }); |
| 432 | } |
| 433 | |
| 434 | |
| 435 |
no test coverage detected