summaryrefslogtreecommitdiff
path: root/src/network.h
diff options
context:
space:
mode:
authorRoman Smrž <roman.smrz@seznam.cz>2020-02-28 21:27:48 +0100
committerRoman Smrž <roman.smrz@seznam.cz>2020-03-10 21:47:29 +0100
commit76d6f638df485d179899fa740b9bb53ee55ba7bc (patch)
tree25039e8ed4d4f637a7f6162b4d101f3871707609 /src/network.h
parent751cdc6c0235a0623ed980b24b71acb85e94dacf (diff)
Network: avoid duplicit items in generated packet
Diffstat (limited to 'src/network.h')
-rw-r--r--src/network.h28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/network.h b/src/network.h
index 07b5363..13bb031 100644
--- a/src/network.h
+++ b/src/network.h
@@ -30,6 +30,8 @@ using chrono::steady_clock;
namespace erebos {
+class ReplyBuilder;
+
struct Server::Peer
{
Peer(const Peer &) = delete;
@@ -54,8 +56,8 @@ struct Server::Peer
shared_ptr<erebos::Peer::Priv> lpeer = nullptr;
void send(const struct TransportHeader &, const vector<Object> &) const;
- void updateIdentity(struct ReplyBuilder &);
- void updateChannel(struct ReplyBuilder &);
+ void updateIdentity(ReplyBuilder &);
+ void updateChannel(ReplyBuilder &);
};
struct Peer::Priv : enable_shared_from_this<Peer::Priv>
@@ -103,6 +105,20 @@ struct TransportHeader
const vector<Item> items;
};
+class ReplyBuilder
+{
+public:
+ void header(TransportHeader::Item &&);
+ void body(const Ref &);
+
+ const vector<TransportHeader::Item> & header() const { return mheader; }
+ vector<Object> body() const;
+
+private:
+ vector<TransportHeader::Item> mheader;
+ vector<Ref> mbody;
+};
+
struct WaitingRef
{
const Storage storage;
@@ -110,13 +126,7 @@ struct WaitingRef
const Server::Peer & peer;
vector<Digest> missing;
- optional<Ref> check(vector<TransportHeader::Item> * request = nullptr);
-};
-
-struct ReplyBuilder
-{
- vector<TransportHeader::Item> header;
- vector<Object> body;
+ optional<Ref> check(ReplyBuilder &);
};
struct Server::Priv