Bomberman Multiplayer
Authoritative multiplayer networking layer for Bomberman.
Loading...
Searching...
No Matches
bomberman::net::PacketDispatcher< TContext > Struct Template Reference

Fixed-size message type to handler lookup table. More...

#include <PacketDispatch.h>

Public Member Functions

void bind (EMsgType type, PacketHandlerFn< TContext > fn)
 Registers a handler for a message type. Overwrites existing binding.
 
bool dispatch (TContext &context, const PacketHeader &header, const uint8_t *payload, std::size_t payloadSize) const
 Looks up and invokes the handler for header.type.
 

Public Attributes

std::array< PacketHandlerFn< TContext >, kTableSize > table {}
 

Static Public Attributes

static constexpr std::size_t kTableSize = 256
 

Detailed Description

template<typename TContext>
struct bomberman::net::PacketDispatcher< TContext >

Fixed-size message type to handler lookup table.

Template Parameters
TContextContext type shared by all bound handlers.

Indexes by raw uint8_t message type. Unbound slots are nullptr.

Member Function Documentation

◆ dispatch()

template<typename TContext >
bool bomberman::net::PacketDispatcher< TContext >::dispatch ( TContext &  context,
const PacketHeader header,
const uint8_t *  payload,
std::size_t  payloadSize 
) const
inline

Looks up and invokes the handler for header.type.

Returns
true if a handler was found and called.

The documentation for this struct was generated from the following file: