Updates from BitShares FC #22
3 changed files with 35 additions and 35 deletions
|
|
@ -28,6 +28,9 @@ namespace fc {
|
|||
/// whereas normally the last two arguments must be provided, this template allows them to be omitted.
|
||||
/// Note that this only applies to trailing optional arguments, i.e. given a callable taking
|
||||
/// (fc::optional<int>, int, fc::optional<int>), only the last argument can be omitted.
|
||||
///
|
||||
/// A discussion of how exactly this works is available here:
|
||||
/// https://github.com/bitshares/bitshares-fc/pull/126#issuecomment-490566060
|
||||
template<typename R, typename... Parameters>
|
||||
struct optionals_callable : public std::function<R(Parameters...)> {
|
||||
using std::function<R(Parameters...)>::operator();
|
||||
|
|
|
|||
|
|
@ -207,8 +207,6 @@ namespace fc { namespace http {
|
|||
_server_thread.async( [&](){
|
||||
auto new_con = std::make_shared<websocket_connection_impl<websocket_server_type::connection_ptr>>( _server.get_con_from_hdl(hdl) );
|
||||
_on_connection( _connections[hdl] = new_con );
|
||||
if ( !_closed || _closed->ready() )
|
||||
_closed = new fc::promise<void>();
|
||||
}).wait();
|
||||
});
|
||||
_server.set_message_handler( [&]( connection_hdl hdl, websocket_server_type::message_ptr msg ){
|
||||
|
|
@ -291,6 +289,9 @@ namespace fc { namespace http {
|
|||
if( _server.is_listening() )
|
||||
_server.stop_listening();
|
||||
|
||||
if ( _connections.size() )
|
||||
_closed = new fc::promise<void>();
|
||||
|
||||
auto cpy_con = _connections;
|
||||
for( auto item : cpy_con )
|
||||
_server.close( item.first, 0, "server exit" );
|
||||
|
|
|
|||
|
|
@ -77,7 +77,6 @@ BOOST_AUTO_TEST_CASE(login_test) {
|
|||
auto listen_port = server->get_listening_port();
|
||||
server->start_accept();
|
||||
|
||||
try {
|
||||
auto client = std::make_shared<fc::http::websocket_client>();
|
||||
auto con = client->connect( "ws://localhost:" + std::to_string(listen_port) );
|
||||
server->stop_listening();
|
||||
|
|
@ -95,7 +94,6 @@ BOOST_AUTO_TEST_CASE(login_test) {
|
|||
client.reset();
|
||||
server.reset();
|
||||
} FC_LOG_AND_RETHROW()
|
||||
} FC_LOG_AND_RETHROW()
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_CASE(optionals_test) {
|
||||
|
|
@ -118,7 +116,6 @@ BOOST_AUTO_TEST_CASE(optionals_test) {
|
|||
auto listen_port = server->get_listening_port();
|
||||
server->start_accept();
|
||||
|
||||
try {
|
||||
auto client = std::make_shared<fc::http::websocket_client>();
|
||||
auto con = client->connect( "ws://localhost:" + std::to_string(listen_port) );
|
||||
server->stop_listening();
|
||||
|
|
@ -136,7 +133,6 @@ BOOST_AUTO_TEST_CASE(optionals_test) {
|
|||
client.reset();
|
||||
server.reset();
|
||||
} FC_LOG_AND_RETHROW()
|
||||
} FC_LOG_AND_RETHROW()
|
||||
}
|
||||
|
||||
BOOST_AUTO_TEST_SUITE_END()
|
||||
|
|
|
|||
Loading…
Reference in a new issue