diff --git a/chat_messages.h b/chat_messages.h deleted file mode 100644 index b80f9e8..0000000 --- a/chat_messages.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#include -#include - - - -enum class message -{ - HELLO = 1, NEPTUN = 2, PASSW = 3, - SERVER_DIRECTION = 4, MESSAGE = 5, - PING = 6, PONG = 7, BYE = 8, - LOGIN = 9, LOGOUT = 10 -}; - - -class chat_message -{ -protected: - virtual message get_command() = 0; - virtual std::string get_content() = 0; -public: -}; - - -class client_message : public chat_message -{ -public: - void send(boost::asio::ip::tcp::socket& socket); -}; - - -class server_message : public chat_message -{ -public: - void receive(boost::asio::ip::tcp::socket& socket); -}; \ No newline at end of file diff --git a/chat_messages.hpp b/chat_messages.hpp new file mode 100644 index 0000000..88265b6 --- /dev/null +++ b/chat_messages.hpp @@ -0,0 +1,30 @@ +#pragma once +#include +#include + + + +enum class message +{ + HELLO = 1, NEPTUN = 2, PASSW = 3, + SERVER_DIRECTION = 4, MESSAGE = 5, + PING = 6, PONG = 7, BYE = 8, + LOGIN = 9, LOGOUT = 10 +}; + + +class chat_message +{ + message _header; + std::string _content; + +public: + chat_message(message header, std::string content) + :_header(header), _content(content) {} + + chat_message(std::underlying_type::type header_integral, std::string content) + :_header(static_cast(header_integral)), _content(content) {} + + std::string get() + { return std::to_string(static_cast::type>(_header)) + _content; } +};