From 0465243c710ede74a78885077140d8673efbc647 Mon Sep 17 00:00:00 2001 From: Determinant Date: Fri, 20 Jul 2018 20:08:59 -0400 Subject: improve msg & msg network interface --- include/salticidae/msg.h | 56 ++++++------------------------------------------ 1 file changed, 7 insertions(+), 49 deletions(-) (limited to 'include/salticidae/msg.h') diff --git a/include/salticidae/msg.h b/include/salticidae/msg.h index 33f0d2b..8a63a50 100644 --- a/include/salticidae/msg.h +++ b/include/salticidae/msg.h @@ -36,14 +36,10 @@ namespace salticidae { -template +template class MsgBase { public: using opcode_t = OpcodeType; - static const opcode_t OPCODE_PING; - static const opcode_t OPCODE_PONG; static const size_t header_size; private: @@ -195,32 +191,6 @@ class MsgBase { return std::move(s); } - void gen_ping(uint16_t port) { - DataStream s; - set_opcode(OPCODE_PING); - s << htole(port); - set_payload(std::move(s)); - } - - void parse_ping(uint16_t &port) const { - DataStream s(get_payload()); - s >> port; - port = letoh(port); - } - - void gen_pong(uint16_t port) { - DataStream s; - set_opcode(OPCODE_PONG); - s << htole(port); - set_payload(std::move(s)); - } - - void parse_pong(uint16_t &port) const { - DataStream s(get_payload()); - s >> port; - port = letoh(port); - } - void gen_hash_list(DataStream &s, const std::vector &hashes) { uint32_t size = htole((uint32_t)hashes.size()); @@ -242,24 +212,12 @@ class MsgBase { }; -template -const size_t MsgBase::header_size = - sizeof(MsgBase::magic) + - sizeof(MsgBase::opcode) + - sizeof(MsgBase::length) + - sizeof(MsgBase::checksum); - -template -const OpcodeType MsgBase::OPCODE_PING = PING; - -template -const OpcodeType MsgBase::OPCODE_PONG = PONG; +template +const size_t MsgBase::header_size = + sizeof(MsgBase::magic) + + sizeof(MsgBase::opcode) + + sizeof(MsgBase::length) + + sizeof(MsgBase::checksum); } -- cgit v1.2.3