summaryrefslogtreecommitdiffstats
path: root/src/Network.hpp
blob: 1281289da92db8d5da493fe2643ebfb25354ec94 (plain) (blame)
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
#pragma once

#include <memory>
#include "Socket.hpp"
#include "Packet.hpp"

enum ConnectionState {
	Handshaking,
	Login,
	Play,
	Status,
};

class Network {
	Socket *socket;
	StreamSocket *stream;

	std::shared_ptr<Packet> ReceivePacketByPacketId(int packetId, ConnectionState state, StreamInput &stream);
public:
	Network(std::string address, unsigned short port);
	~Network();

	std::shared_ptr<Packet> ReceivePacket(ConnectionState state = Play);
	void SendPacket(Packet &packet);
	std::shared_ptr<Packet> ParsePacketPlay(PacketNamePlayCB id);
};