blob: fadeee30013009d9a1f3ce2678eb0a72323e55fd (
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 "PacketListener.h"
#include "InteractPacket.h"
const int InteractPacket::INTERACT = 0;
const int InteractPacket::ATTACK = 1;
InteractPacket::InteractPacket()
{
source = 0;
target = 0;
action = 0;
}
InteractPacket::InteractPacket(int source, int target, int action)
{
this->source = source;
this->target = target;
this->action = action;
}
void InteractPacket::read(DataInputStream *dis) //throws IOException
{
source = dis->readInt();
target = dis->readInt();
action = dis->readByte();
}
void InteractPacket::write(DataOutputStream *dos) // throws IOException
{
dos->writeInt(source);
dos->writeInt(target);
dos->writeByte(action);
}
void InteractPacket::handle(PacketListener *listener)
{
listener->handleInteract(shared_from_this());
}
int InteractPacket::getEstimatedSize()
{
return 9;
}
|