diff options
Diffstat (limited to 'src/network/Network.hpp')
-rw-r--r-- | src/network/Network.hpp | 42 |
1 files changed, 20 insertions, 22 deletions
diff --git a/src/network/Network.hpp b/src/network/Network.hpp index 84f2e7f..1281289 100644 --- a/src/network/Network.hpp +++ b/src/network/Network.hpp @@ -1,28 +1,26 @@ #pragma once -#include <string> -#include <easylogging++.h> -#include <SFML/Network.hpp> -#include "../packet/Packet.hpp" -#include "../packet/PacketBuilder.hpp" - +#include <memory> +#include "Socket.hpp" +#include "Packet.hpp" + +enum ConnectionState { + Handshaking, + Login, + Play, + Status, +}; class Network { -public: - Network(std::string address, unsigned short port); - - ~Network(); - - void SendHandshake(std::string username); + Socket *socket; + StreamSocket *stream; - void SendPacket(Packet &packet); - - Packet ReceivePacket(); - -private: - std::string m_address; - unsigned short m_port; - sf::TcpSocket m_socket; - bool m_isCommpress=false; -}; + 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); +};
\ No newline at end of file |