Skip to content

Commit

Permalink
Updated packet class
Browse files Browse the repository at this point in the history
  • Loading branch information
Nelonn committed Feb 18, 2024
1 parent 5fd83d5 commit 731e605
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
2 changes: 0 additions & 2 deletions Source/Runtime/Core/network/protocol/packet.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@


#include "packet.h"

#include <map>
Expand Down
14 changes: 10 additions & 4 deletions Source/Runtime/Core/network/protocol/packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,20 @@
#include "../../connection_context.h"
#include "../byte_buffer.h"

class ServerboundPacket {
class Packet {

public:
[[nodiscard]] virtual int getPacketID() const = 0;
};

// TODO: merge into Packet class
class ServerboundPacket : public Packet {
public:
ServerboundPacket();

public:
virtual void read(ByteBuffer&) = 0;
virtual ServerboundPacket* createInstance() = 0;
[[nodiscard]] virtual int getPacketID() const = 0;
virtual void handle(ConnectionContext*) = 0;

public:
Expand All @@ -22,11 +28,11 @@ class ServerboundPacket {
static ServerboundPacket* createInstanceFromID(int, ConnectionState);
};

class ClientboundPacket {
// TODO: merge into Packet class
class ClientboundPacket : public Packet {
public:
ClientboundPacket();

public:
virtual void write(ByteBuffer&) = 0;
[[nodiscard]] virtual int getPacketID() const = 0;
};

0 comments on commit 731e605

Please sign in to comment.