CatapultServer
v0.5.0.1 (Elephant)
|
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 PacketHandler * | findHandler (const Packet &packet) const |
Private Attributes | |
uint32_t | m_maxPacketDataSize |
std::vector< PacketHandler > | m_handlers |
A collection of packet handlers where there is at most one handler per packet type.
Handler context type.
using catapult::ionet::ServerPacketHandlers::PacketHandler = consumer<const Packet&, ContextType&> |
Packet handler function.
|
explicit |
Creates packet handlers with a max packet data size (maxPacketDataSize).
bool catapult::ionet::ServerPacketHandlers::canProcess | ( | const Packet & | packet | ) | const |
Determines if packet can be processed by a registered handler.
bool catapult::ionet::ServerPacketHandlers::canProcess | ( | PacketType | type | ) | const |
Determines if type can be processed by a registered handler.
|
private |
uint32_t catapult::ionet::ServerPacketHandlers::maxPacketDataSize | ( | ) | const |
Gets the max packet data size.
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.
void catapult::ionet::ServerPacketHandlers::registerHandler | ( | PacketType | type, |
const PacketHandler & | handler | ||
) |
Registers a handler for the specified packet type.
size_t catapult::ionet::ServerPacketHandlers::size | ( | ) | const |
Gets the number of registered handlers.
|
private |
|
private |