diff options
Diffstat (limited to 'src/network/protocol.h')
-rw-r--r-- | src/network/protocol.h | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/src/network/protocol.h b/src/network/protocol.h index c5803ce..df29c05 100644 --- a/src/network/protocol.h +++ b/src/network/protocol.h @@ -106,7 +106,17 @@ struct NetworkProtocol::ConnectionReadReady { Connection::Id id; }; struct NetworkProtocol::Header { - enum class Type { + struct Acknowledged { Digest value; }; + struct DataRequest { Digest value; }; + struct DataResponse { Digest value; }; + struct AnnounceSelf { Digest value; }; + struct AnnounceUpdate { Digest value; }; + struct ChannelRequest { Digest value; }; + struct ChannelAccept { Digest value; }; + struct ServiceType { UUID value; }; + struct ServiceRef { Digest value; }; + + using Item = variant< Acknowledged, DataRequest, DataResponse, @@ -115,16 +125,7 @@ struct NetworkProtocol::Header ChannelRequest, ChannelAccept, ServiceType, - ServiceRef, - }; - - struct Item { - const Type type; - const variant<Digest, UUID> value; - - bool operator==(const Item &) const; - bool operator!=(const Item & other) const { return !(*this == other); } - }; + ServiceRef>; Header(const vector<Item> & items): items(items) {} static optional<Header> load(const PartialRef &); @@ -134,6 +135,11 @@ struct NetworkProtocol::Header const vector<Item> items; }; +bool operator==(const NetworkProtocol::Header::Item &, const NetworkProtocol::Header::Item &); +inline bool operator!=(const NetworkProtocol::Header::Item & left, + const NetworkProtocol::Header::Item & right) +{ return not (left == right); } + class ReplyBuilder { public: |