mirror of
https://github.com/Xahau/xahaud.git
synced 2025-11-27 22:15:49 +00:00
Reorganize source files
This commit is contained in:
@@ -8,17 +8,17 @@
|
||||
import os ;
|
||||
|
||||
exe http_crawl :
|
||||
../beast/http/src/beast_http_nodejs_parser.cpp
|
||||
../src/beast_http_nodejs_parser.cpp
|
||||
http_crawl.cpp
|
||||
urls_large_data.cpp
|
||||
;
|
||||
|
||||
exe http_server :
|
||||
../beast/http/src/beast_http_nodejs_parser.cpp
|
||||
../src/beast_http_nodejs_parser.cpp
|
||||
http_server.cpp
|
||||
;
|
||||
|
||||
exe wsproto_echo :
|
||||
../beast/http/src/beast_http_nodejs_parser.cpp
|
||||
../src/beast_http_nodejs_parser.cpp
|
||||
wsproto_echo.cpp
|
||||
;
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#ifndef BEAST_EXAMPLE_FILE_BODY_H_INCLUDED
|
||||
#define BEAST_EXAMPLE_FILE_BODY_H_INCLUDED
|
||||
|
||||
#include <beast/http/message.h>
|
||||
#include <beast/http/resume_context.h>
|
||||
#include <beast/http/message.hpp>
|
||||
#include <beast/http/resume_context.hpp>
|
||||
#include <boost/asio/buffer.hpp>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <cstdio>
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "file_body.h"
|
||||
#include "http_stream.h"
|
||||
|
||||
#include <beast/asio/placeholders.h>
|
||||
#include <beast/placeholders.hpp>
|
||||
#include <boost/asio.hpp>
|
||||
#include <cstdio>
|
||||
#include <iostream>
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
/*
|
||||
This file is part of Beast: https://github.com/vinniefalco/Beast
|
||||
Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted, provided that the above
|
||||
copyright notice and this permission notice appear in all copies.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#ifndef BEAST_HTTP_EXAMPLE_SERVER_RESPONSE_H_INCLUDED
|
||||
#define BEAST_HTTP_EXAMPLE_SERVER_RESPONSE_H_INCLUDED
|
||||
|
||||
namespace beast {
|
||||
namespace http {
|
||||
namespace example {
|
||||
|
||||
} // example
|
||||
} // http
|
||||
} // beast
|
||||
|
||||
#endif
|
||||
@@ -20,8 +20,8 @@
|
||||
#ifndef BEAST_HTTP_STREAM_H_INCLUDED
|
||||
#define BEAST_HTTP_STREAM_H_INCLUDED
|
||||
|
||||
#include <beast/http.h>
|
||||
#include <beast/asio/basic_streambuf.h>
|
||||
#include <beast/http.hpp>
|
||||
#include <beast/basic_streambuf.hpp>
|
||||
#include <boost/asio/io_service.hpp>
|
||||
#include <boost/intrusive/list.hpp>
|
||||
#include <memory>
|
||||
|
||||
@@ -20,12 +20,12 @@
|
||||
#ifndef BEAST_HTTP_STREAM_IPP_INCLUDED
|
||||
#define BEAST_HTTP_STREAM_IPP_INCLUDED
|
||||
|
||||
#include <beast/asio/async_completion.h>
|
||||
#include <beast/asio/bind_handler.h>
|
||||
#include <beast/asio/handler_alloc.h>
|
||||
#include <beast/http/read.h>
|
||||
#include <beast/http/type_check.h>
|
||||
#include <beast/http/write.h>
|
||||
#include <beast/async_completion.hpp>
|
||||
#include <beast/bind_handler.hpp>
|
||||
#include <beast/handler_alloc.hpp>
|
||||
#include <beast/http/read.hpp>
|
||||
#include <beast/http/type_check.hpp>
|
||||
#include <beast/http/write.hpp>
|
||||
#include <cassert>
|
||||
|
||||
namespace beast {
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "file_body.h"
|
||||
#include "http_stream.h"
|
||||
|
||||
#include <beast/unit_test/suite.h>
|
||||
#include <boost/asio.hpp>
|
||||
#include <cstdint>
|
||||
#include <cstdio>
|
||||
|
||||
@@ -20,9 +20,9 @@
|
||||
#ifndef BEAST_WSPROTO_ASYNC_ECHO_PEER_H_INCLUDED
|
||||
#define BEAST_WSPROTO_ASYNC_ECHO_PEER_H_INCLUDED
|
||||
|
||||
#include <beast/asio/placeholders.h>
|
||||
#include <beast/asio/streambuf.h>
|
||||
#include <beast/wsproto.h>
|
||||
#include <beast/placeholders.hpp>
|
||||
#include <beast/streambuf.hpp>
|
||||
#include <beast/websocket.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <thread>
|
||||
|
||||
namespace beast {
|
||||
namespace wsproto {
|
||||
namespace websocket {
|
||||
|
||||
// Asynchronous WebSocket echo client/server
|
||||
//
|
||||
@@ -94,8 +94,8 @@ private:
|
||||
{
|
||||
int state = 0;
|
||||
boost::optional<endpoint_type> ep;
|
||||
wsproto::socket<socket_type> ws;
|
||||
wsproto::opcode op;
|
||||
websocket::stream<socket_type> ws;
|
||||
websocket::opcode op;
|
||||
beast::streambuf sb;
|
||||
int id;
|
||||
|
||||
@@ -197,13 +197,13 @@ private:
|
||||
|
||||
// got message
|
||||
case 2:
|
||||
if(ec == wsproto::error::closed)
|
||||
if(ec == websocket::error::closed)
|
||||
return;
|
||||
if(ec)
|
||||
return fail(ec, "async_read");
|
||||
// write message
|
||||
d.state = 1;
|
||||
d.ws.set_option(wsproto::message_type(d.op));
|
||||
d.ws.set_option(websocket::message_type(d.op));
|
||||
d.ws.async_write(d.sb.data(), std::move(*this));
|
||||
return;
|
||||
|
||||
@@ -224,7 +224,7 @@ private:
|
||||
void
|
||||
fail(error_code ec, std::string what)
|
||||
{
|
||||
if(ec != wsproto::error::closed)
|
||||
if(ec != websocket::error::closed)
|
||||
std::cerr << "#" << d_->id << " " <<
|
||||
what << ": " << ec.message() << std::endl;
|
||||
}
|
||||
@@ -261,7 +261,7 @@ private:
|
||||
}
|
||||
};
|
||||
|
||||
} // wsproto
|
||||
} // websocket
|
||||
} // beast
|
||||
|
||||
#endif
|
||||
|
||||
@@ -19,35 +19,18 @@
|
||||
|
||||
#include "wsproto_async_echo_peer.h"
|
||||
#include "wsproto_sync_echo_peer.h"
|
||||
#include <boost/asio.hpp>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include "sig_wait.h"
|
||||
|
||||
int main()
|
||||
{
|
||||
using endpoint_type = boost::asio::ip::tcp::endpoint;
|
||||
using address_type = boost::asio::ip::address;
|
||||
|
||||
beast::wsproto::async_echo_peer s1(true, endpoint_type{
|
||||
beast::websocket::async_echo_peer s1(true, endpoint_type{
|
||||
address_type::from_string("127.0.0.1"), 6000 }, 4);
|
||||
|
||||
beast::wsproto::sync_echo_peer s2(true, endpoint_type{
|
||||
beast::websocket::sync_echo_peer s2(true, endpoint_type{
|
||||
address_type::from_string("127.0.0.1"), 6001 });
|
||||
|
||||
boost::asio::io_service ios;
|
||||
boost::asio::signal_set signals(
|
||||
ios, SIGINT, SIGTERM);
|
||||
std::mutex m;
|
||||
bool stop = false;
|
||||
std::condition_variable cv;
|
||||
signals.async_wait(
|
||||
[&](boost::system::error_code const& ec,
|
||||
int signal_number)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(m);
|
||||
stop = true;
|
||||
cv.notify_one();
|
||||
});
|
||||
std::unique_lock<std::mutex> lock(m);
|
||||
cv.wait(lock, [&]{ return stop; });
|
||||
sig_wait();
|
||||
}
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
#ifndef BEAST_WSPROTO_SYNC_ECHO_PEER_H_INCLUDED
|
||||
#define BEAST_WSPROTO_SYNC_ECHO_PEER_H_INCLUDED
|
||||
|
||||
#include <beast/asio/streambuf.h>
|
||||
#include <beast/wsproto.h>
|
||||
#include <beast/streambuf.hpp>
|
||||
#include <beast/websocket.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
#include <functional>
|
||||
#include <iostream>
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <thread>
|
||||
|
||||
namespace beast {
|
||||
namespace wsproto {
|
||||
namespace websocket {
|
||||
|
||||
// Synchronous WebSocket echo client/server
|
||||
//
|
||||
@@ -144,7 +144,7 @@ private:
|
||||
void
|
||||
do_peer(int id, socket_type&& sock)
|
||||
{
|
||||
wsproto::socket<socket_type> ws(std::move(sock));
|
||||
websocket::stream<socket_type> ws(std::move(sock));
|
||||
ws.set_option(decorate(identity{}));
|
||||
ws.set_option(read_message_max(64 * 1024 * 1024));
|
||||
error_code ec;
|
||||
@@ -156,24 +156,24 @@ private:
|
||||
}
|
||||
for(;;)
|
||||
{
|
||||
wsproto::opcode op;
|
||||
websocket::opcode op;
|
||||
beast::streambuf sb;
|
||||
ws.read(op, sb, ec);
|
||||
if(ec)
|
||||
break;
|
||||
ws.set_option(wsproto::message_type(op));
|
||||
ws.set_option(websocket::message_type(op));
|
||||
ws.write(sb.data(), ec);
|
||||
if(ec)
|
||||
break;
|
||||
}
|
||||
if(ec && ec != wsproto::error::closed)
|
||||
if(ec && ec != websocket::error::closed)
|
||||
{
|
||||
fail(id, ec, "read");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
} // wsproto
|
||||
} // websocket
|
||||
} // beast
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user