From 76d6f638df485d179899fa740b9bb53ee55ba7bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Fri, 28 Feb 2020 21:27:48 +0100 Subject: Network: avoid duplicit items in generated packet --- src/network.h | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) (limited to 'src/network.h') 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 lpeer = nullptr; void send(const struct TransportHeader &, const vector &) const; - void updateIdentity(struct ReplyBuilder &); - void updateChannel(struct ReplyBuilder &); + void updateIdentity(ReplyBuilder &); + void updateChannel(ReplyBuilder &); }; struct Peer::Priv : enable_shared_from_this @@ -103,6 +105,20 @@ struct TransportHeader const vector items; }; +class ReplyBuilder +{ +public: + void header(TransportHeader::Item &&); + void body(const Ref &); + + const vector & header() const { return mheader; } + vector body() const; + +private: + vector mheader; + vector mbody; +}; + struct WaitingRef { const Storage storage; @@ -110,13 +126,7 @@ struct WaitingRef const Server::Peer & peer; vector missing; - optional check(vector * request = nullptr); -}; - -struct ReplyBuilder -{ - vector header; - vector body; + optional check(ReplyBuilder &); }; struct Server::Priv -- cgit v1.2.3