解决编译错误
This commit is contained in:
parent
248c45c0eb
commit
1c318f6e3c
@ -1,3 +1,6 @@
|
||||
#include <boost/beast/core.hpp>
|
||||
#include <boost/beast/websocket.hpp>
|
||||
#include <boost/asio/ip/tcp.hpp>
|
||||
#include "network/WebSocketServer.h"
|
||||
#include "utils/Logger.h"
|
||||
#include <nlohmann/json.hpp>
|
||||
@ -91,12 +94,12 @@ void WebSocketServer::handleAccept() {
|
||||
|
||||
void WebSocketServer::doRead(std::shared_ptr<boost::beast::websocket::stream<boost::asio::ip::tcp::socket>> ws) {
|
||||
// 为每个会话创建一个专用的缓冲区
|
||||
auto buffer = std::make_shared<boost::beast::flat_buffer>();
|
||||
auto buffer = std::make_shared<boost::beast::multi_buffer>();
|
||||
|
||||
// 异步读取消息
|
||||
ws->async_read(
|
||||
*buffer,
|
||||
[this, ws, buffer](boost::system::error_code ec, std::size_t bytes_transferred) {
|
||||
[this, ws, buffer = buffer](boost::system::error_code ec, std::size_t bytes_transferred) {
|
||||
if (!ec) {
|
||||
// 成功读取消息,继续读取下一条
|
||||
buffer->consume(buffer->size()); // 清空缓冲区
|
||||
|
||||
Loading…
Reference in New Issue
Block a user