summaryrefslogtreecommitdiff
path: root/src/net/netcomputer.cpp
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-11-19 13:36:50 +0000
committerDavid Athay <ko2fan@gmail.com>2008-11-19 15:02:10 +0000
commit8481413ea17177945d3d280b1518eb6f1f25cd5d (patch)
tree77ed689d7587a6d06c07dd81c3ca0d5c49b3284d /src/net/netcomputer.cpp
parent751cc20a3be820724ca575aab32c2bb424f89a5b (diff)
downloadmanaserv-8481413ea17177945d3d280b1518eb6f1f25cd5d.tar.gz
manaserv-8481413ea17177945d3d280b1518eb6f1f25cd5d.tar.bz2
manaserv-8481413ea17177945d3d280b1518eb6f1f25cd5d.tar.xz
manaserv-8481413ea17177945d3d280b1518eb6f1f25cd5d.zip
Added bandwidth monitoring
Diffstat (limited to 'src/net/netcomputer.cpp')
-rw-r--r--src/net/netcomputer.cpp40
1 files changed, 35 insertions, 5 deletions
diff --git a/src/net/netcomputer.cpp b/src/net/netcomputer.cpp
index d5b0ea77..657f615b 100644
--- a/src/net/netcomputer.cpp
+++ b/src/net/netcomputer.cpp
@@ -23,15 +23,19 @@
#include <queue>
#include <enet/enet.h>
-#include "defines.h"
-#include "net/messageout.hpp"
-#include "net/netcomputer.hpp"
-#include "utils/logger.h"
-#include "utils/processorutils.hpp"
+#include "bandwidth.hpp"
+#include "messageout.hpp"
+#include "netcomputer.hpp"
+
+#include "../defines.h"
+
+#include "../utils/logger.h"
+#include "../utils/processorutils.hpp"
NetComputer::NetComputer(ENetPeer *peer):
mPeer(peer)
{
+ mBandwidth = new BandwidthMonitor;
}
bool
@@ -64,6 +68,8 @@ NetComputer::send(const MessageOut &msg, bool reliable,
{
LOG_DEBUG("Sending message " << msg << " to " << *this);
+ mBandwidth->increaseOutput(msg.getLength());
+
ENetPacket *packet;
packet = enet_packet_create(msg.getData(),
msg.getLength(),
@@ -79,6 +85,30 @@ NetComputer::send(const MessageOut &msg, bool reliable,
}
}
+int
+NetComputer::totalOut()
+{
+ return mBandwidth->totalOut();
+}
+
+int
+NetComputer::totalIn()
+{
+ return mBandwidth->totalIn();
+}
+
+void
+NetComputer::increaseIn(int size)
+{
+ mBandwidth->increaseInput(size);
+}
+
+void
+NetComputer::reset()
+{
+ mBandwidth->reset();
+}
+
std::ostream&
operator <<(std::ostream &os, const NetComputer &comp)
{