71 namespace Connection {
109 template<typename Callable>
113 m_context(new
std::decay_t<Callable>(
std::forward<Callable>(callable))),
114 m_invoke(&Invoke<
std::decay_t<Callable>>),
115 m_clone(&Clone<
std::decay_t<Callable>>),
116 m_destroy(&Destroy<
std::decay_t<Callable>>) {}
155 StormByte::Safe::Shared<Logger::Log> logger) const;
158 explicit operator
bool() const noexcept {
159 return m_context !=
nullptr;
172 template<
typename Callable>
175 return (*
static_cast<Callable*
>(context))(opcode, std::move(payload), std::move(logger));
184 template<
typename Callable>
185 static void* Clone(
const void* context) {
186 return new Callable(*
static_cast<const Callable*
>(context));
194 template<
typename Callable>
195 static void Destroy(
void* context)
noexcept {
196 delete static_cast<Callable*
>(context);
199 void* m_context =
nullptr;
Connection or socket operation failed.
Definition exception.hxx:118
Caller-owned callback that builds a packet from opcode and payload.
Definition typedefs.hxx:94
~DeserializePacketFunction() noexcept
Destroy through the caller's destruction trampoline.
Transport::Packet::OpcodeType OpcodeType
Wire opcode type.
Definition typedefs.hxx:96
DeserializePacketFunction(DeserializePacketFunction &&other) noexcept
Transfer callback ownership without touching its target.
void(*)(void *) noexcept DestroyFunction
Caller-allocator destroy trampoline.
Definition typedefs.hxx:99
void *(*)(const void *) CloneFunction
Caller-allocator clone trampoline.
Definition typedefs.hxx:98
PacketPointer(*)(void *, OpcodeType, Buffer::Consumer, StormByte::Safe::Shared< Logger::Log >) InvokeFunction
Invocation trampoline.
Definition typedefs.hxx:97
DeserializePacketFunction() noexcept=default
Empty callback.
DeserializePacketFunction(const DeserializePacketFunction &other)
Clone using the caller's target allocator trampoline.
unsigned short OpcodeType
Opcode storage type.
Definition packet.hxx:61
int HandlerType
Native socket handle (POSIX)
Definition typedefs.hxx:73
Network module of the StormByte suite.
Definition client.hxx:54
StormByte::Expected< std::shared_ptr< Socket::Client >, ConnectionError > ExpectedClient
Accept result.
Definition typedefs.hxx:81
StormByte::Expected< Connection::Read::Result, ConnectionClosed > ExpectedReadResult
Wait-for-data result.
Definition typedefs.hxx:82
std::shared_ptr< Transport::Packet > PacketPointer
Shared packet.
Definition typedefs.hxx:83
StormByte::Expected< void, ConnectionError > ExpectedVoid
Void operation result.
Definition typedefs.hxx:80
StormByte::Expected< Buffer::FIFO, ConnectionError > ExpectedBuffer
Receive buffer result.
Definition typedefs.hxx:79
Root namespace of the StormByte suite.
std::conditional_t< Type::Reference< T >, std::expected< std::reference_wrapper< std::remove_reference_t< T > >, Safe::Shared< E > >, std::expected< T, Safe::Shared< E > > > Expected
#define STORMBYTE_NETWORK_PUBLIC
Definition visibility.h:51