summaryrefslogtreecommitdiff
path: root/src/net/netcomputer.cpp
diff options
context:
space:
mode:
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)
{