Open objects76 opened 4 years ago
On examples/client/main.cpp....
client.subscribe("key", [](string_view data) { std::cout << csprintf("%d.%d ", gettid(), LINE).c_str() << "key= " << &data[1] << "\n"; std::cout << "what is first char of string_view is " << (int)data[0] << std::endl; });
the data is packed....
so I've changed callback_sub in rpc_client.cpp. Is it right? thank you...
void callback_sub(const boost::system::error_code& ec, string_view result) { .... //it->second(data); rpc_service::msgpack_codec codec2; auto str = codec2.unpack<std::string>(data.data(), data.size()); it->second(str); .... }
yes, you need do serialization for the result.
You could call as to deserialize, it's more simple. If not match the type you will get an exception.
as<string>(result)
Thank you ... I've update with as(result);
On examples/client/main.cpp....
client.subscribe("key", [](string_view data) { std::cout << csprintf("%d.%d ", gettid(), LINE).c_str() << "key= " << &data[1] << "\n"; std::cout << "what is first char of string_view is " << (int)data[0] << std::endl; });
the data is packed....
so I've changed callback_sub in rpc_client.cpp. Is it right? thank you...