added function byte(message) for more readable message->byte conversion

This commit is contained in:
Kjistóf 2016-12-03 13:50:09 +01:00
parent 9c9118c34d
commit 9c8f985210
1 changed files with 2 additions and 2 deletions

View File

@ -14,6 +14,7 @@ namespace chat
PING = 6, PONG = 7, BYE = 8,
LOGIN = 9, LOGOUT = 10, TERM = 0x7f
};
char byte(message msg) { return static_cast<char>(msg); }
class chat_message
@ -31,10 +32,9 @@ namespace chat
{}
std::string get() const
{ return static_cast<char>(_header) + _content + static_cast<char>(message::TERM); }
{ return byte(_header) + _content + byte(message::TERM); }
};
std::ostream& operator<<(std::ostream& os, const chat_message& msg)
{ return os << msg.get(); }
}