mirror of
https://github.com/Xahau/xahaud.git
synced 2025-12-06 17:27:52 +00:00
06f74f0 Set version to 1.0.0-b26 68f535f Tidy up warnings and tests: 4ee5fa9 Set version to 1.0.0-b25 229d390 Update README.md for CppCast 2017 c3e3a55 Fix deflate setup bug 439a224 WebSocket server examples and test tidying: 29565c8 Remove unnecessary include caa3b39 Fix 32-bit arm7 warnings 0474cc5 Better handler_ptr (API Change): ca38657 Fixes for websocket echo server: 797631c Set version to 1.0.0-b24 a450968 Add permessage-deflate WebSocket extension: 67e965e Make decorator copyable 42899fc Add optional yield_to arguments 61aef03 Simplify Travis package install specification 9d0d7c9 bjam use clang on MACOSX git-subtree-dir: src/beast git-subtree-split: 06f74f05f7de51d7f791a17c2b06840183332cbe
57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
//
|
|
// Copyright (c) 2013-2016 Vinnie Falco (vinnie dot falco at gmail dot com)
|
|
//
|
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
|
//
|
|
|
|
#include "websocket_async_echo_server.hpp"
|
|
#include "websocket_sync_echo_server.hpp"
|
|
#include <boost/asio/io_service.hpp>
|
|
#include <boost/asio/signal_set.hpp>
|
|
#include <iostream>
|
|
|
|
/// Block until SIGINT or SIGTERM is received.
|
|
void
|
|
sig_wait()
|
|
{
|
|
boost::asio::io_service ios;
|
|
boost::asio::signal_set signals(
|
|
ios, SIGINT, SIGTERM);
|
|
signals.async_wait(
|
|
[&](boost::system::error_code const&, int)
|
|
{
|
|
});
|
|
ios.run();
|
|
}
|
|
|
|
int main()
|
|
{
|
|
using namespace beast::websocket;
|
|
using endpoint_type = boost::asio::ip::tcp::endpoint;
|
|
using address_type = boost::asio::ip::address;
|
|
|
|
beast::error_code ec;
|
|
|
|
permessage_deflate pmd;
|
|
pmd.client_enable = true;
|
|
pmd.server_enable = true;
|
|
pmd.compLevel = 3;
|
|
|
|
websocket::async_echo_server s1{&std::cout, 1};
|
|
s1.set_option(read_message_max{64 * 1024 * 1024});
|
|
s1.set_option(auto_fragment{false});
|
|
s1.set_option(pmd);
|
|
s1.open(endpoint_type{
|
|
address_type::from_string("127.0.0.1"), 6000 }, ec);
|
|
|
|
websocket::sync_echo_server s2{&std::cout};
|
|
s2.set_option(read_message_max{64 * 1024 * 1024});
|
|
s2.set_option(auto_fragment{false});
|
|
s2.set_option(pmd);
|
|
s2.open(endpoint_type{
|
|
address_type::from_string("127.0.0.1"), 6001 }, ec);
|
|
|
|
sig_wait();
|
|
}
|