aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/DisconnectPacket.cpp
blob: 0b6f6bf8060fec2fa656551fb0cf25e422c8986d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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 = static_cast<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;
}