CatapultServer  v0.5.0.1 (Elephant)
catapult::ionet::ServerPacketHandlers Class Reference

A collection of packet handlers where there is at most one handler per packet type. More...

Public Types

using ContextType = ServerPacketHandlerContext
 Handler context type. More...
 
using PacketHandler = consumer< const Packet &, ContextType & >
 Packet handler function. More...
 

Public Member Functions

 ServerPacketHandlers (uint32_t maxPacketDataSize=std::numeric_limits< uint32_t >::max())
 Creates packet handlers with a max packet data size (maxPacketDataSize). More...
 
size_t size () const
 Gets the number of registered handlers. More...
 
uint32_t maxPacketDataSize () const
 Gets the max packet data size. More...
 
bool canProcess (PacketType type) const
 Determines if type can be processed by a registered handler. More...
 
bool canProcess (const Packet &packet) const
 Determines if packet can be processed by a registered handler. More...
 
bool process (const Packet &packet, ContextType &context) const
 
void registerHandler (PacketType type, const PacketHandler &handler)
 Registers a handler for the specified packet type. More...
 

Private Member Functions

const PacketHandlerfindHandler (const Packet &packet) const
 

Private Attributes

uint32_t m_maxPacketDataSize
 
std::vector< PacketHandlerm_handlers
 

Detailed Description

A collection of packet handlers where there is at most one handler per packet type.

Member Typedef Documentation

◆ ContextType

◆ PacketHandler

Constructor & Destructor Documentation

◆ ServerPacketHandlers()

catapult::ionet::ServerPacketHandlers::ServerPacketHandlers ( uint32_t  maxPacketDataSize = std::numeric_limits<uint32_t>::max())
explicit

Creates packet handlers with a max packet data size (maxPacketDataSize).

Member Function Documentation

◆ canProcess() [1/2]

bool catapult::ionet::ServerPacketHandlers::canProcess ( const Packet packet) const

Determines if packet can be processed by a registered handler.

Here is the call graph for this function:

◆ canProcess() [2/2]

bool catapult::ionet::ServerPacketHandlers::canProcess ( PacketType  type) const

Determines if type can be processed by a registered handler.

◆ findHandler()

const ServerPacketHandlers::PacketHandler * catapult::ionet::ServerPacketHandlers::findHandler ( const Packet packet) const
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ maxPacketDataSize()

uint32_t catapult::ionet::ServerPacketHandlers::maxPacketDataSize ( ) const

Gets the max packet data size.

Here is the caller graph for this function:

◆ process()

bool catapult::ionet::ServerPacketHandlers::process ( const Packet packet,
ContextType context 
) const

Processes packet using the specified context and returns true if the packet was processed.

Here is the call graph for this function:

◆ registerHandler()

void catapult::ionet::ServerPacketHandlers::registerHandler ( PacketType  type,
const PacketHandler handler 
)

Registers a handler for the specified packet type.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ size()

size_t catapult::ionet::ServerPacketHandlers::size ( ) const

Gets the number of registered handlers.

Member Data Documentation

◆ m_handlers

std::vector<PacketHandler> catapult::ionet::ServerPacketHandlers::m_handlers
private

◆ m_maxPacketDataSize

uint32_t catapult::ionet::ServerPacketHandlers::m_maxPacketDataSize
private

The documentation for this class was generated from the following files: