rebase server

This commit is contained in:
Nathan Nichols
2021-06-14 09:51:16 -05:00
committed by CJ Cobb
parent 357405f32c
commit 9720f169bb
13 changed files with 509 additions and 122 deletions

View File

@@ -15,10 +15,8 @@
#include <boost/asio/dispatch.hpp>
#include <boost/asio/strand.hpp>
#include <boost/beast/core.hpp>
#include <boost/beast/websocket.hpp>
#include <boost/json.hpp>
#include <boost/log/core.hpp>
#include <boost/log/expressions.hpp>
#include <boost/log/trivial.hpp>
@@ -145,14 +143,19 @@ start(boost::asio::io_context& ioc, std::uint32_t numThreads)
for (auto i = numThreads - 1; i > 0; --i)
v.emplace_back([&ioc] { ioc.run(); });
ioc.run();
std::make_shared<Listener<HttpSession, SslHttpSession>>(
ioc,
ctx,
boost::asio::ip::tcp::endpoint{address, port},
etl)
->run();
}
int
main(int argc, char* argv[])
{
// Check command line arguments.
if (argc < 3 || argc > 6)
if (argc < 5 || argc > 6)
{
std::cerr
<< "Usage: websocket-server-async <threads> "
@@ -165,9 +168,7 @@ main(int argc, char* argv[])
auto const threads = std::max<int>(1, std::atoi(argv[1]));
auto const config = parse_config(argv[2]);
std::optional<ssl::context> ctx = {};
if (argc == 4 || argc == 5)
ctx = parse_certs(argv[3], argv[4]);
std::optional<ssl::context> ctx = parse_certs(argv[3], argv[4]);
if (argc > 5)
{
@@ -180,9 +181,13 @@ main(int argc, char* argv[])
if (!config)
{
std::cerr << "couldnt parse config. Exiting..." << std::endl;
std::cerr << "Ccouldnt parse config. Exiting..." << std::endl;
return EXIT_FAILURE;
}
if (!ctx)
{
std::cerr << "Couldn't parse SSL certificates" << std::endl;
}
boost::asio::io_context ioc{threads};