diff --git a/include/ki/protocol/net/DMLSession.h b/include/ki/protocol/net/DMLSession.h index 8245dc6..345b563 100644 --- a/include/ki/protocol/net/DMLSession.h +++ b/include/ki/protocol/net/DMLSession.h @@ -8,6 +8,12 @@ namespace protocol { namespace net { + enum class InvalidDMLMessageErrorCode + { + INVALID_MESSAGE_DATA, + INSUFFICIENT_ACCESS + }; + /** * Implements an application protocol that uses the DML * message system (as seen in Wizard101 and Pirate101). @@ -24,7 +30,7 @@ namespace net protected: void on_application_message(const PacketHeader& header) override; virtual void on_message(const dml::Message &message) {} - virtual void on_invalid_message() {} + virtual void on_invalid_message(InvalidDMLMessageErrorCode error) {} private: const dml::MessageManager &m_manager; }; diff --git a/src/protocol/net/DMLSession.cpp b/src/protocol/net/DMLSession.cpp index f11a7ed..aec5c48 100644 --- a/src/protocol/net/DMLSession.cpp +++ b/src/protocol/net/DMLSession.cpp @@ -21,10 +21,11 @@ namespace net void DMLSession::on_application_message(const PacketHeader& header) { + // Attempt to create a Message instance from the data in the stream const auto *message = m_manager.message_from_binary(m_data_stream); if (!message) { - on_invalid_message(); + on_invalid_message(InvalidDMLMessageErrorCode::INVALID_MESSAGE_DATA); return; } @@ -32,7 +33,7 @@ namespace net if (get_access_level() >= message->get_access_level()) on_message(*message); else - on_invalid_message(); + on_invalid_message(InvalidDMLMessageErrorCode::INSUFFICIENT_ACCESS); delete message; } }