Skip to content

Commit

Permalink
Basic Packet class and Opcode enum placeholder
Browse files Browse the repository at this point in the history
  • Loading branch information
DDuarte committed Jul 5, 2012
1 parent 26bb746 commit e308ed6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/LeEngine/LeEngine.vcxproj
Expand Up @@ -25,6 +25,8 @@
<ClInclude Include="Log.h" />
<ClInclude Include="DMath.h" />
<ClInclude Include="Matrix.h" />
<ClInclude Include="Opcode.h" />
<ClInclude Include="Packet.h" />
<ClInclude Include="Plane.h" />
<ClInclude Include="Quaternion.h" />
<ClInclude Include="Random.h" />
Expand Down
6 changes: 6 additions & 0 deletions src/LeEngine/LeEngine.vcxproj.filters
Expand Up @@ -90,6 +90,12 @@
<ClInclude Include="ByteBuffer.h">
<Filter>Networking</Filter>
</ClInclude>
<ClInclude Include="Packet.h">
<Filter>Networking</Filter>
</ClInclude>
<ClInclude Include="Opcode.h">
<Filter>Networking</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Log.cpp">
Expand Down
16 changes: 16 additions & 0 deletions src/LeEngine/Opcode.h
@@ -0,0 +1,16 @@
#ifndef OPCODE_H
#define OPCODE_H

enum Opcode
{
NONE = 0,
CMSG_TEXT_MESSAGE = 1,
};

enum Direction
{
ClientToServer = 0, // CMSG
ServerToClient = 1, // SMSG
};

#endif // OPCODE_H
27 changes: 27 additions & 0 deletions src/LeEngine/Packet.h
@@ -0,0 +1,27 @@
#ifndef PACKET_H
#define PACKET_H

#include "ByteBuffer.h"
#include "Opcode.h"
#include "Defines.h"

class Packet : public ByteBuffer
{
protected:
// uint32 _time; // unix time
// uint8 _direction; // enum Direction
uint16 _opcode; // enum Opcode
// uint32 _length;
// Byte* _data;

public:
Packet() : ByteBuffer(0), _opcode(0) {}
Packet(Opcode opcode, uint32 reserveSize) : ByteBuffer(reserveSize), _opcode((uint16)opcode) {}
Packet(const Packet& other) : ByteBuffer(other), _opcode(other._opcode) {}

Opcode GetOpcode() const { _return (Opcode)_opcode; }
void SetOpcode(Opcode opcode) { _opcode = opcode; }

};

#endif // PACKET_H

0 comments on commit e308ed6

Please sign in to comment.