StormByte C++ Library: Network module 1.1.0
StormByte-Network is the C++26 networking module of the StormByte suite.
Loading...
Searching...
No Matches
typedefs.hxx
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2026 David C. Manuelda (StormBytePP)
3 *
4 * This file is part of StormByte-Network.
5 *
6 * StormByte-Network is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU Lesser General Public License version 3
8 * or later, as published by the Free Software Foundation.
9 *
10 * StormByte-Network is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with StormByte-Network. If not, see
17 * <https://www.gnu.org/licenses/lgpl-3.0.html>.
18 */
19
20#pragma once
21
22#include <StormByte/buffer/fifo.hxx>
23#include <StormByte/expected.hxx>
24#include <StormByte/logger/log.hxx>
30
31#ifdef WINDOWS
32#include <winsock2.h>
33#endif
34
35#include <functional>
36#include <memory>
37
41namespace StormByte::Network {
42 namespace Socket {
43 class Socket;
44 class Client;
45 }
46
47 namespace Connection {
48 #ifdef UNIX
49 using HandlerType = int;
50 #else
51 using HandlerType = SOCKET;
52 #endif
53 }
54
55 using ExpectedBuffer = StormByte::Expected<Buffer::FIFO, ConnectionError>;
56 using ExpectedVoid = StormByte::Expected<void, ConnectionError>;
57 using ExpectedClient = StormByte::Expected<std::shared_ptr<Socket::Client>, ConnectionError>;
58 using ExpectedReadResult = StormByte::Expected<Connection::Read::Result, ConnectionClosed>;
59 using PacketPointer = std::shared_ptr<Transport::Packet>;
60
66 Buffer::Consumer,
67 std::shared_ptr<Logger::Log>
68 )>;
69}
Connection or socket operation failed.
Definition exception.hxx:53
unsigned short OpcodeType
Opcode storage type.
Definition packet.hxx:40
int HandlerType
Native socket handle (POSIX)
Definition typedefs.hxx:49
Network module of the StormByte suite.
Definition client.hxx:30
StormByte::Expected< std::shared_ptr< Socket::Client >, ConnectionError > ExpectedClient
Accept result.
Definition typedefs.hxx:57
std::function< PacketPointer(Transport::Packet::OpcodeType, Buffer::Consumer, std::shared_ptr< Logger::Log >)> DeserializePacketFunction
Callback that builds a Packet from opcode + payload consumer.
Definition typedefs.hxx:68
StormByte::Expected< Connection::Read::Result, ConnectionClosed > ExpectedReadResult
Wait-for-data result.
Definition typedefs.hxx:58
std::shared_ptr< Transport::Packet > PacketPointer
Shared packet.
Definition typedefs.hxx:59
StormByte::Expected< void, ConnectionError > ExpectedVoid
Void operation result.
Definition typedefs.hxx:56
StormByte::Expected< Buffer::FIFO, ConnectionError > ExpectedBuffer
Receive buffer result.
Definition typedefs.hxx:55