FeatherMC/src/Protocol.h

48 lines
952 B
C
Raw Normal View History

#pragma once
2020-08-01 02:36:29 +01:00
#include "Common.h"
#include "NetworkMessage.h"
2020-08-01 00:55:47 +01:00
#include <cstdio>
2020-08-01 22:53:02 +01:00
#include <cstdint>
namespace Feather
{
2020-08-01 02:36:29 +01:00
class DedicatedServer;
class PacketReader;
class MinecraftClient;
2020-08-01 22:53:02 +01:00
enum class ProtocolState : int32_t
{
Handholding = -1,
Play = 0,
Status = 1,
Login = 2,
};
class ProtocolContext
{
public:
inline ProtocolState GetState() const
{
return m_state;
}
inline void SetState(ProtocolState state)
{
2020-08-01 02:36:29 +01:00
Log_Info("Setting state: %d", (int)state);
m_state = state;
}
private:
ProtocolState m_state = ProtocolState::Handholding;
};
class Protocol
{
2020-08-01 02:36:29 +01:00
DedicatedServer& m_server;
public:
2020-08-01 02:36:29 +01:00
Protocol(DedicatedServer& server) : m_server(server) {}
void HandlePacket(MinecraftClient& client, PacketReader& packet);
};
2020-08-01 00:55:47 +01:00
}