diff --git a/example/pub_sub_example/pub_client_example.cpp b/example/pub_sub_example/pub_client_example.cpp index fccc008..fa927b6 100644 --- a/example/pub_sub_example/pub_client_example.cpp +++ b/example/pub_sub_example/pub_client_example.cpp @@ -55,10 +55,10 @@ int main(void) while (true) { using namespace std::chrono_literals; - //async_client->call(endpoint, client::add_pub, lhs, rhs++); - //std::this_thread::sleep_for(1s); - async_client->pub(endpoint, client::sub_add, rhs++); - std::this_thread::sleep_for(1s); + async_client->call(endpoint, client::add_pub, lhs, rhs++); + std::this_thread::sleep_for(200ms); + async_client->pub(endpoint, client::sub_add, rhs); + std::this_thread::sleep_for(200ms); } } catch (timax::rpc::exception const& e) diff --git a/rest_rpc/client/detail/async_client_private.hpp b/rest_rpc/client/detail/async_client_private.hpp index fd2bc2b..64fde8d 100644 --- a/rest_rpc/client/detail/async_client_private.hpp +++ b/rest_rpc/client/detail/async_client_private.hpp @@ -97,6 +97,11 @@ namespace timax { namespace rpc sub_manager_.sub(endpoint, protocol, std::forward(func), std::forward(efunc)); } + uint64_t hash(std::string const& topic) const + { + return hash_(topic); + } + private: io_service_t& ios_; rpc_manager_t rpc_manager_; diff --git a/rest_rpc/client/detail/async_sub_channel.hpp b/rest_rpc/client/detail/async_sub_channel.hpp index c395c4a..46e995d 100644 --- a/rest_rpc/client/detail/async_sub_channel.hpp +++ b/rest_rpc/client/detail/async_sub_channel.hpp @@ -145,6 +145,7 @@ namespace timax { namespace rpc if (!(connection_.socket().is_open() && running_flag_.load())) return; + std::memset(&send_head_, 0, sizeof(req_header)); if (!error) { async_read(connection_.socket(), boost::asio::buffer(&recv_head_, sizeof(recv_head_)), boost::bind(