added function byte(message) for more readable message->byte conversion
This commit is contained in:
parent
9c9118c34d
commit
9c8f985210
@ -14,6 +14,7 @@ namespace chat
|
|||||||
PING = 6, PONG = 7, BYE = 8,
|
PING = 6, PONG = 7, BYE = 8,
|
||||||
LOGIN = 9, LOGOUT = 10, TERM = 0x7f
|
LOGIN = 9, LOGOUT = 10, TERM = 0x7f
|
||||||
};
|
};
|
||||||
|
char byte(message msg) { return static_cast<char>(msg); }
|
||||||
|
|
||||||
|
|
||||||
class chat_message
|
class chat_message
|
||||||
@ -31,10 +32,9 @@ namespace chat
|
|||||||
{}
|
{}
|
||||||
|
|
||||||
std::string get() const
|
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)
|
std::ostream& operator<<(std::ostream& os, const chat_message& msg)
|
||||||
{ return os << msg.get(); }
|
{ return os << msg.get(); }
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user