2016-11-29 16:54:00 +00:00
|
|
|
#pragma once
|
|
|
|
#include <string>
|
|
|
|
#include <type_traits>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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:
|
2016-11-29 17:46:09 +00:00
|
|
|
chat_message(message header, std::string content = "")
|
2016-11-29 16:54:00 +00:00
|
|
|
:_header(header), _content(content) {}
|
|
|
|
|
|
|
|
chat_message(std::underlying_type<message>::type header_integral, std::string content)
|
|
|
|
:_header(static_cast<message>(header_integral)), _content(content) {}
|
|
|
|
|
2016-11-29 18:14:06 +00:00
|
|
|
std::string get() const
|
2016-11-29 16:54:00 +00:00
|
|
|
{ return std::to_string(static_cast<std::underlying_type<message>::type>(_header)) + _content; }
|
|
|
|
};
|