From f8c57c8e24262a29d629f766e3c72f42fd91ed77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kjist=C3=B3f?= Date: Sat, 3 Dec 2016 11:51:27 +0100 Subject: [PATCH] fixed chat_message: now enum class message has underlying type of char --- chat_messages.hpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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