Project

General

Profile

Bug #13087 ยป asiowrapper.patch

Velvet Jones, 10/07/2024 04:30 PM

View differences:

src/Wt/WWebSocketConnection.C
writeBuffer_.append(data.data(), data.size());
// Put data into asio::buffer actual write buffer
using namespace boost::asio;
using namespace AsioWrapper::asio;
std::vector<const_buffer> buffer;
writeBuffer_.asioBuffers(buffer);
......
// Put data into asio::buffer actual write buffer
writeBuffer_.append(frameHeader.data(), frameHeader.size());
using namespace boost::asio;
using namespace AsioWrapper::asio;
std::vector<const_buffer> buffer;
writeBuffer_.asioBuffers(buffer);
......
void WebSocketTcpConnection::doSocketRead(char* buffer, size_t size)
{
using namespace boost::asio;
using namespace AsioWrapper::asio;
socket_->async_read_some(boost::asio::buffer(buffer, size), strand_.wrap(std::bind(&WebSocketTcpConnection::handleAsyncRead, shared_from_this(), std::placeholders::_1, std::placeholders::_2)));
socket_->async_read_some(AsioWrapper::asio::buffer(buffer, size), strand_.wrap(std::bind(&WebSocketTcpConnection::handleAsyncRead, shared_from_this(), std::placeholders::_1, std::placeholders::_2)));
}
void WebSocketTcpConnection::doSocketWrite(const std::vector<boost::asio::const_buffer>& buffer, OpCode type)
void WebSocketTcpConnection::doSocketWrite(const std::vector<AsioWrapper::asio::const_buffer>& buffer, OpCode type)
{
async_write(socket(), buffer, strand_.wrap(std::bind(&WebSocketTcpConnection::handleAsyncWritten, shared_from_this(), type, std::placeholders::_1, std::placeholders::_2)));
}
......
void WebSocketSslConnection::doSocketRead(char* buffer, size_t size)
{
using namespace boost::asio;
using namespace AsioWrapper::asio;
socket_->async_read_some(boost::asio::buffer(buffer, size), strand_.wrap(std::bind(&WebSocketSslConnection::handleAsyncRead, shared_from_this(), std::placeholders::_1, std::placeholders::_2)));
socket_->async_read_some(AsioWrapper::asio::buffer(buffer, size), strand_.wrap(std::bind(&WebSocketSslConnection::handleAsyncRead, shared_from_this(), std::placeholders::_1, std::placeholders::_2)));
}
void WebSocketSslConnection::doSocketWrite(const std::vector<boost::asio::const_buffer>& buffer, OpCode type)
void WebSocketSslConnection::doSocketWrite(const std::vector<AsioWrapper::asio::const_buffer>& buffer, OpCode type)
{
async_write(*socket_, buffer, strand_.wrap(std::bind(&WebSocketSslConnection::handleAsyncWritten, shared_from_this(), type, std::placeholders::_1, std::placeholders::_2)));
}
src/Wt/WWebSocketConnection.h
virtual void doSocketRead(char* buffer, size_t size) = 0;
// Performs an async write to the socket, inside the write-done loop.
virtual void doSocketWrite(const std::vector<boost::asio::const_buffer>& buffer, OpCode type) = 0;
virtual void doSocketWrite(const std::vector<AsioWrapper::asio::const_buffer>& buffer, OpCode type) = 0;
private:
// Buffer & parsing
......
bool hasPendingPingWrite_;
bool hasPendingPongWrite_;
OpCode pendingWriteDataType_;
std::vector<boost::asio::const_buffer> pendingWritePingBuffer_;
std::vector<boost::asio::const_buffer> pendingWritePongBuffer_;
std::vector<boost::asio::const_buffer> pendingWriteDataBuffer_;
std::vector<AsioWrapper::asio::const_buffer> pendingWritePingBuffer_;
std::vector<AsioWrapper::asio::const_buffer> pendingWritePongBuffer_;
std::vector<AsioWrapper::asio::const_buffer> pendingWriteDataBuffer_;
std::function<void()> hasDataReadCallback_;
std::function<void(const AsioWrapper::error_code&, std::size_t)> hasDataWrittenCallback_;
......
protected:
void doSocketRead(char* input, size_t offset) final;
void doSocketWrite(const std::vector<boost::asio::const_buffer>& buffer, OpCode type) final;
void doSocketWrite(const std::vector<AsioWrapper::asio::const_buffer>& buffer, OpCode type) final;
private:
std::unique_ptr<Socket> socket_;
......
protected:
void doSocketRead(char* input, size_t offset) final;
void doSocketWrite(const std::vector<boost::asio::const_buffer>& buffer, OpCode type) final;
void doSocketWrite(const std::vector<AsioWrapper::asio::const_buffer>& buffer, OpCode type) final;
private:
std::unique_ptr<SSLSocket> socket_;
    (1-1/1)