diff --git a/chat_messages.hpp b/chat_messages.hpp index 7c745c7..f014cf2 100644 --- a/chat_messages.hpp +++ b/chat_messages.hpp @@ -1,15 +1,16 @@ #pragma once #include #include +#include -enum class message +enum class message : char { HELLO = 1, NEPTUN = 2, PASSW = 3, SERVER_DIRECTION = 4, MESSAGE = 5, PING = 6, PONG = 7, BYE = 8, - LOGIN = 9, LOGOUT = 10 + LOGIN = 9, LOGOUT = 10, TERM = 0x7f }; @@ -26,5 +27,9 @@ public: :_header(static_cast(header_integral)), _content(content) {} std::string get() const - { return std::to_string(static_cast::type>(_header)) + _content; } + { return static_cast(_header) + _content + static_cast(message::TERM); } }; + + +std::ostream& operator<<(std::ostream& os, const chat_message& msg) +{ return os << msg.get(); } \ No newline at end of file