MCPcopy Create free account
hub / github.com/chronoxor/CppServer / request

Method request

proto/simple_protocol.cpp:294–319  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294std::future<::simple::SimpleResponse> Client::request(const ::simple::SimpleRequest& value, uint64_t timeout)
295{
296 std::scoped_lock locker(this->_lock);
297
298 std::promise<::simple::SimpleResponse> promise;
299 std::future<::simple::SimpleResponse> future = promise.get_future();
300
301 uint64_t current = utc();
302
303 // Send the request message
304 size_t serialized = Sender::send(value);
305 if (serialized > 0)
306 {
307 // Calculate the unique timestamp
308 this->_timestamp = (current <= this->_timestamp) ? this->_timestamp + 1 : current;
309
310 // Register the request
311 _requests_by_id_SimpleResponse.insert(std::make_pair(value.id, std::make_tuple(this->_timestamp, timeout * 1000000, std::move(promise))));
312 if (timeout > 0)
313 _requests_by_timestamp_SimpleResponse.insert(std::make_pair(this->_timestamp, value.id));
314 }
315 else
316 promise.set_exception(std::make_exception_ptr(std::runtime_error("Send request failed!")));
317
318 return future;
319}
320
321std::future<void> Client::request(const ::simple::DisconnectRequest& value, uint64_t timeout)
322{

Callers 2

test_proto.cppFile · 0.80
mainFunction · 0.80

Calls 2

utcFunction · 0.85
insertMethod · 0.80

Tested by

no test coverage detected