diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-03-31 10:23:00 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2007-03-31 10:23:00 +0000 |
commit | eba3a8635b308475aa4bcfc5f5cd058c48ed679d (patch) | |
tree | c6c44e6d8d53f97d6fed0177fe5a07ce432a4b0e /src/net/messageout.cpp | |
parent | bd9b9a04c0ec07c957014d0679d386c7b42e5312 (diff) | |
download | manaserv-eba3a8635b308475aa4bcfc5f5cd058c48ed679d.tar.gz manaserv-eba3a8635b308475aa4bcfc5f5cd058c48ed679d.tar.bz2 manaserv-eba3a8635b308475aa4bcfc5f5cd058c48ed679d.tar.xz manaserv-eba3a8635b308475aa4bcfc5f5cd058c48ed679d.zip |
Moved writing of outgoing messages into MessageOut and added printing of the
message ID.
Diffstat (limited to 'src/net/messageout.cpp')
-rw-r--r-- | src/net/messageout.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/net/messageout.cpp b/src/net/messageout.cpp index 34655e4c..929514a6 100644 --- a/src/net/messageout.cpp +++ b/src/net/messageout.cpp @@ -24,6 +24,8 @@ #include <cstdlib> #include <iosfwd> #include <string> +#include <iostream> +#include <iomanip> #include <enet/enet.h> #include "net/messageout.hpp" @@ -133,3 +135,21 @@ MessageOut::writeString(const std::string &string, int length) } mPos += length; } + +std::ostream& +operator <<(std::ostream &os, const MessageOut &msg) +{ + if (msg.getLength() >= 2) + { + unsigned short id = ENET_NET_TO_HOST_16(*(short*) msg.mData); + os << std::setw(6) << std::hex << std::showbase << std::internal + << std::setfill('0') << id + << std::dec << " (" << msg.getLength() << " B)"; + } + else + { + os << "Unknown" + << std::dec << " (" << msg.getLength() << " B)"; + } + return os; +} |