summaryrefslogtreecommitdiffstats
path: root/src/network/Network.hpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-06-17 16:23:53 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-06-17 16:23:53 +0200
commit789f70b6f1a9067843dfc1ff73d86b645efe1da9 (patch)
treef3db085f2ac1ec5fd6ad0869a63e77a7f0fb1a17 /src/network/Network.hpp
parent2017-06-14 (diff)
downloadAltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar
AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar.gz
AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar.bz2
AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar.lz
AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar.xz
AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.tar.zst
AltCraft-789f70b6f1a9067843dfc1ff73d86b645efe1da9.zip
Diffstat (limited to 'src/network/Network.hpp')
-rw-r--r--src/network/Network.hpp42
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