aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/DisconnectPacket.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Minecraft.World/DisconnectPacket.cpp')
-rw-r--r--Minecraft.World/DisconnectPacket.cpp48
1 files changed, 48 insertions, 0 deletions
diff --git a/Minecraft.World/DisconnectPacket.cpp b/Minecraft.World/DisconnectPacket.cpp
new file mode 100644
index 00000000..da20686a
--- /dev/null
+++ b/Minecraft.World/DisconnectPacket.cpp
@@ -0,0 +1,48 @@
+#include "stdafx.h"
+#include <iostream>
+#include "InputOutputStream.h"
+#include "SharedConstants.h"
+#include "PacketListener.h"
+#include "DisconnectPacket.h"
+
+
+
+DisconnectPacket::DisconnectPacket()
+{
+ reason = eDisconnect_None;
+}
+
+DisconnectPacket::DisconnectPacket(eDisconnectReason reason)
+{
+ this->reason = reason;
+}
+
+void DisconnectPacket::read(DataInputStream *dis) //throws IOException
+{
+ reason = (eDisconnectReason)dis->readInt();
+}
+
+void DisconnectPacket::write(DataOutputStream *dos) //throws IOException
+{
+ dos->writeInt((int)reason);
+}
+
+void DisconnectPacket::handle(PacketListener *listener)
+{
+ listener->handleDisconnect(shared_from_this());
+}
+
+int DisconnectPacket::getEstimatedSize()
+{
+ return sizeof(eDisconnectReason);
+}
+
+bool DisconnectPacket::canBeInvalidated()
+{
+ return true;
+}
+
+bool DisconnectPacket::isInvalidatedBy(shared_ptr<Packet> packet)
+{
+ return true;
+} \ No newline at end of file