StormByte C++ Library: Network module 0.0.9999
StormByte-Network is a StormByte library module for handling and create network connections
Loading...
Searching...
No Matches
handler.hxx
1#pragma once
2
3#include <StormByte/network/typedefs.hxx>
4
5#ifdef WINDOWS
6#include <winsock2.h>
7#endif
8
9#include <string>
10
15namespace StormByte::Network::Connection {
16 class STORMBYTE_NETWORK_PUBLIC Handler {
17 public:
18 #ifdef LINUX
19 using Type = int;
20 #else
21 using Type = SOCKET;
22 #endif
23
28 Handler(const PacketInstanceFunction& packet_instance_function) noexcept;
29
34 Handler(const Handler& other) = delete;
35
40 Handler(Handler&& other) noexcept = delete;
41
45 ~Handler() noexcept;
46
52 Handler& operator=(const Handler& other) = delete;
53
59 Handler& operator=(Handler&& other) noexcept = delete;
60
65 std::string LastError() const noexcept;
66
71 int LastErrorCode() const noexcept;
72
78
79 private:
80 bool m_initialized = false;
81 #ifdef WINDOWS
82 WSADATA m_wsaData;
83 #endif
84 const Network::PacketInstanceFunction m_packet_instance_function;
85 };
86}
SOCKET Type
The type of the socket.
Definition handler.hxx:21
~Handler() noexcept
The destructor of the Handler class.
Handler(const Handler &other)=delete
The copy constructor of the Handler class.
Handler(const PacketInstanceFunction &packet_instance_function) noexcept
The constructor of the Handler class.
Handler(Handler &&other) noexcept=delete
The move constructor of the Handler class.
std::function< std::shared_ptr< Packet >(const unsigned short &)> PacketInstanceFunction
The packet instance function type.
Definition typedefs.hxx:39