1#ifndef joedb_rpc_Client_declared
2#define joedb_rpc_Client_declared
22 const std::vector<Signature> &signatures;
32 lock->write((
const char *)h.data(), h.size() *
sizeof h[0]);
33 lock->read(buffer.
data, 9);
37 if (buffer.
read<
char>() !=
'H')
39 session_id = buffer.
read<int64_t>();
55 const std::vector<Signature> &signatures,
56 std::chrono::milliseconds keep_alive_interval = std::chrono::milliseconds(0)
59 signatures(signatures),
60 keep_alive(*this, keep_alive_interval)
69 auto &signature = signatures[procedure_id];
73 const int64_t from = int64_t(signature.prolog.size());
74 const int64_t until = file.
get_size();
77 buffer.
write<
char>(
'C');
78 buffer.
write<int64_t>(procedure_id);
79 buffer.
write<int64_t>(until);
83 lock->write(file.
get_data().data() + from, until - from);
84 lock->read(buffer.
data, 9);
88 const char reply = buffer.
read<
char>();
92 const size_t from = file.
get_data().size();
93 const int64_t until = buffer.
read<int64_t>();
94 file.
get_data().resize(
size_t(until));
95 lock->read(file.
get_data().data() + from, size_t(until) - from);
96 file.
pwrite((
const char *)&until, 8, 0);
97 file.
pwrite((
const char *)&until, 8, 8);
101 const int64_t n = buffer.
read<int64_t>();
102 std::string error_message;
103 error_message.resize(n);
104 lock->read(error_message.data(), n);
char data[size+extra_size]
void pwrite(const char *buffer, size_t size, int64_t offset) override
Write a range of bytes. Extend file size if necessary.
int64_t get_size() const override
Get the size of the file, or -1 if it is unknown.
std::array< uint32_t, 8 > Hash
Client(Channel &channel, const std::vector< Signature > &signatures, std::chrono::milliseconds keep_alive_interval=std::chrono::milliseconds(0))
void call(int64_t procedure_id, Memory_File &file)
SHA_256::Hash get_hash(const std::vector< Signature > &signatures)
Compute hash code for a collection of procedure signatures.