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