From 59aa21b4b6a5f45aa3d9efa8ad06972bfde63b27 Mon Sep 17 00:00:00 2001 From: Joshua Scott Date: Wed, 11 Apr 2018 01:18:31 +0100 Subject: [PATCH] net: Implement send_message on DMLSession --- include/ki/protocol/control/Opcode.h | 1 + include/ki/protocol/net/DMLSession.h | 2 ++ src/protocol/net/DMLSession.cpp | 5 +++++ 3 files changed, 8 insertions(+) diff --git a/include/ki/protocol/control/Opcode.h b/include/ki/protocol/control/Opcode.h index 8442a56..85ee88e 100644 --- a/include/ki/protocol/control/Opcode.h +++ b/include/ki/protocol/control/Opcode.h @@ -9,6 +9,7 @@ namespace control { enum class Opcode : uint8_t { + NONE = 0, SERVER_HELLO = 0, UDP_HELLO = 1, PING = 3, diff --git a/include/ki/protocol/net/DMLSession.h b/include/ki/protocol/net/DMLSession.h index 0963db1..3b0c66e 100644 --- a/include/ki/protocol/net/DMLSession.h +++ b/include/ki/protocol/net/DMLSession.h @@ -14,6 +14,8 @@ namespace net DMLSession(ParticipantType type, uint16_t id, const dml::MessageManager &manager); ~DMLSession() = default; + + void send_message(const dml::Message &message); protected: void on_application_message(const PacketHeader& header) override; virtual void on_message(const dml::Message &message) {} diff --git a/src/protocol/net/DMLSession.cpp b/src/protocol/net/DMLSession.cpp index a794ca8..de524ed 100644 --- a/src/protocol/net/DMLSession.cpp +++ b/src/protocol/net/DMLSession.cpp @@ -10,6 +10,11 @@ namespace net const dml::MessageManager& manager) : Session(type, id), m_manager(manager) {} + void DMLSession::send_message(const dml::Message& message) + { + send_packet(false, control::Opcode::NONE, message); + } + void DMLSession::on_application_message(const PacketHeader& header) { const auto *message = m_manager.message_from_binary(m_data_stream);