summaryrefslogtreecommitdiff
path: root/src/net/messageout.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/messageout.cpp')
-rw-r--r--src/net/messageout.cpp20
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;
+}