Skip to content

Commit

Permalink
Try fix build error
Browse files Browse the repository at this point in the history
  • Loading branch information
Noisyfox committed Mar 17, 2024
1 parent d28e517 commit 45df4ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
15 changes: 8 additions & 7 deletions src/slic3r/GUI/HttpServer.cpp
Expand Up @@ -31,7 +31,7 @@ void session::start()
void session::stop()
{
boost::system::error_code ignored_ec;
socket.shutdown(socket_base::shutdown_both, ignored_ec);
socket.shutdown(boost::asio::socket_base::shutdown_both, ignored_ec);
socket.close(ignored_ec);
}

Expand All @@ -47,7 +47,7 @@ void session::read_first_line()
std::getline(stream, ignore, '\n');
headers.on_read_request_line(line);
read_next_line();
} else if (e != error::operation_aborted) {
} else if (e != boost::asio::error::operation_aborted) {
server.stop(self);
}
});
Expand All @@ -59,7 +59,7 @@ void session::read_body()

int nbuffer = 1000;
std::shared_ptr<std::vector<char>> bufptr = std::make_shared<std::vector<char>>(nbuffer);
async_read(socket, buffer(*bufptr, nbuffer),
async_read(socket, boost::asio::buffer(*bufptr, nbuffer),
[this, self](const boost::beast::error_code& e, std::size_t s) { server.stop(self); });
}

Expand All @@ -82,7 +82,8 @@ void session::read_next_line()
std::stringstream ssOut;
resp->write_response(ssOut);
std::shared_ptr<std::string> str = std::make_shared<std::string>(ssOut.str());
async_write(socket, buffer(str->c_str(), str->length()), [this, self](const boost::beast::error_code& e, std::size_t s) {
async_write(socket, boost::asio::buffer(str->c_str(), str->length()),
[this, self](const boost::beast::error_code& e, std::size_t s) {
std::cout << "done" << std::endl;
server.stop(self);
});
Expand All @@ -92,15 +93,15 @@ void session::read_next_line()
} else {
read_next_line();
}
} else if (e != error::operation_aborted) {
} else if (e != boost::asio::error::operation_aborted) {
server.stop(self);
}
});
}

void HttpServer::IOServer::do_accept()
{
acceptor.async_accept([this](boost::system::error_code ec, ip::tcp::socket socket) {
acceptor.async_accept([this](boost::system::error_code ec, boost::asio::ip::tcp::socket socket) {
if (!acceptor.is_open()) {
return;
}
Expand Down Expand Up @@ -135,7 +136,7 @@ void HttpServer::IOServer::stop_all()
}


HttpServer::HttpServer(ip::port_type port) : port(port) {}
HttpServer::HttpServer(boost::asio::ip::port_type port) : port(port) {}

void HttpServer::start()
{
Expand Down
17 changes: 7 additions & 10 deletions src/slic3r/GUI/HttpServer.hpp
Expand Up @@ -13,9 +13,6 @@
#include <string>
#include <memory>

using namespace boost::system;
using namespace boost::asio;

#define LOCALHOST_PORT 13618
#define LOCALHOST_URL "http://localhost:"

Expand Down Expand Up @@ -72,7 +69,7 @@ class http_headers

class HttpServer
{
ip::port_type port;
boost::asio::ip::port_type port;

public:
class Response
Expand All @@ -99,7 +96,7 @@ class HttpServer
void write_response(std::stringstream& ssOut) override;
};

HttpServer(ip::port_type port = LOCALHOST_PORT);
HttpServer(boost::asio::ip::port_type port = LOCALHOST_PORT);

boost::thread m_http_server_thread;
bool start_http_server = false;
Expand All @@ -116,11 +113,11 @@ class HttpServer
{
public:
HttpServer& server;
io_service io_service;
ip::tcp::acceptor acceptor;
boost::asio::io_service io_service;
boost::asio::ip::tcp::acceptor acceptor;
std::set<std::shared_ptr<session>> sessions;

IOServer(HttpServer& server) : server(server), acceptor(io_service, {ip::tcp::v4(), server.port}) {}
IOServer(HttpServer& server) : server(server), acceptor(io_service, {boost::asio::ip::tcp::v4(), server.port}) {}

void do_accept();

Expand All @@ -138,7 +135,7 @@ class HttpServer
class session : public std::enable_shared_from_this<session>
{
HttpServer::IOServer& server;
ip::tcp::socket socket;
boost::asio::ip::tcp::socket socket;

boost::asio::streambuf buff;
http_headers headers;
Expand All @@ -148,7 +145,7 @@ class session : public std::enable_shared_from_this<session>
void read_body();

public:
session(HttpServer::IOServer& server, ip::tcp::socket socket) : server(server), socket(std::move(socket)) {}
session(HttpServer::IOServer& server, boost::asio::ip::tcp::socket socket) : server(server), socket(std::move(socket)) {}

void start();
void stop();
Expand Down
2 changes: 1 addition & 1 deletion src/slic3r/Utils/SimplyPrint.cpp
Expand Up @@ -10,7 +10,7 @@

namespace Slic3r {

static constexpr ip::port_type CALLBACK_PORT = 21328;
static constexpr boost::asio::ip::port_type CALLBACK_PORT = 21328;
static const std::string CALLBACK_URL = "http://localhost:21328/callback";
static const std::string RESPONSE_TYPE = "code";
static const std::string CLIENT_ID = "simplyprintorcaslicer";
Expand Down

0 comments on commit 45df4ed

Please sign in to comment.