From 789f70b6f1a9067843dfc1ff73d86b645efe1da9 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Sat, 17 Jun 2017 19:23:53 +0500 Subject: 2017-06-17 --- src/network/Network.hpp | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) (limited to 'src/network/Network.hpp') 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 -#include -#include -#include "../packet/Packet.hpp" -#include "../packet/PacketBuilder.hpp" - +#include +#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 ReceivePacketByPacketId(int packetId, ConnectionState state, StreamInput &stream); +public: + Network(std::string address, unsigned short port); + ~Network(); + std::shared_ptr ReceivePacket(ConnectionState state = Play); + void SendPacket(Packet &packet); + std::shared_ptr ParsePacketPlay(PacketNamePlayCB id); +}; \ No newline at end of file -- cgit v1.2.3