From c4630ae970f5d6c0c564327edd380c7b55cefbc9 Mon Sep 17 00:00:00 2001 From: Joshua Scott Date: Wed, 11 Apr 2018 01:12:53 +0100 Subject: [PATCH] net: Session::send_packet was unnecessarily templated --- include/ki/protocol/net/Session.h | 19 +++---------------- src/protocol/net/Session.cpp | 12 ++++++++++++ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/include/ki/protocol/net/Session.h b/include/ki/protocol/net/Session.h index 4b43479..fe97b1d 100644 --- a/include/ki/protocol/net/Session.h +++ b/include/ki/protocol/net/Session.h @@ -31,23 +31,10 @@ namespace net uint16_t get_latency() const; bool is_alive() const; + + void send_packet(bool is_control, control::Opcode opcode, + const util::Serializable &data); protected: - template - void send_packet(const bool is_control, const control::Opcode opcode, - const DataT &data) - { - static_assert(std::is_base_of::value, - "DataT must inherit Serializable."); - - std::ostringstream ss; - PacketHeader header(is_control, (uint8_t)opcode); - header.write_to(ss); - data.write_to(ss); - - const auto buffer = ss.str(); - send_data(buffer.c_str(), buffer.length()); - } - template DataT read_data() { diff --git a/src/protocol/net/Session.cpp b/src/protocol/net/Session.cpp index 3b1dd24..9e5e77b 100644 --- a/src/protocol/net/Session.cpp +++ b/src/protocol/net/Session.cpp @@ -60,6 +60,18 @@ namespace net ).count() <= 10; } + void Session::send_packet(const bool is_control, const control::Opcode opcode, + const util::Serializable& data) + { + std::ostringstream ss; + PacketHeader header(is_control, (uint8_t)opcode); + header.write_to(ss); + data.write_to(ss); + + const auto buffer = ss.str(); + send_data(buffer.c_str(), buffer.length()); + } + void Session::on_connected() { // If this is the server-side of a Session