cpp/yijinjing/src/journal/page_provider.cpp
/** send req via socket and get response in data */
send req via socket and get response in data
send req via socket and get response in data
json ClientPageProvider::request(const string &path)
{
#ifdef _WINDOWS
    int pid = _getpid();
#else
    int pid = getpid();
#endif
    request_["request"] = path;
    request_["pid"] = pid;
    request_["name"] = client_name_;
    request_["writer"] = is_writer_;
    request_["hash_code"] = hash_code_;
    string request_str = request_.dump();
    int sent_bytes = client_request_socket_.send(request_str, 0);
    SPDLOG_TRACE("sent request [{}]: {}", sent_bytes, request_str);
    emitter_.poke();
    int rc = client_request_socket_.recv();
    string response_str = client_request_socket_.last_message();
    SPDLOG_TRACE("got response [{}]: {}", rc, response_str);
    return json::parse(response_str);
}
json ClientPageProvider :: request ( const string & path ) { #ifdef _WINDOWS int pid = _getpid ( ) ; #else int pid = getpid ( ) ; #endif request_ [ " " ] = path ; request_ [ " " ] = pid ; request_ [ " " ] = client_name_ ; request_ [ " " ] = is_writer_ ; request_ [ " " ] = hash_code_ ; string request_str = request_ . dump ( ) ; int sent_bytes = client_request_socket_ . send ( request_str , 0 ) ; SPDLOG_TRACE ( " " , sent_bytes , request_str ) ; emitter_ . poke ( ) ; int rc = client_request_socket_ . recv ( ) ; string response_str = client_request_socket_ . last_message ( ) ; SPDLOG_TRACE ( " " , rc , response_str ) ; return json :: parse ( response_str ) ; }
send req via socket and get response in data
send req via socket and get response in data