Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
Router Class Reference

Routes incoming network messages to registered handlers. More...

#include <router.h>

Public Member Functions

void register_handler (MessageType type, std::function< void(const Message &)> handler)
 Registers a handler for a specific message type. If the handler already exists, it will be overwritten.
 
void unregister_handler (MessageType type)
 Unregisters the handler associated with a message type.
 
void route (const Message &msg) const
 Routes the message to its corresponding handler. If no handler exists, the message is ignored.
 

Detailed Description

Routes incoming network messages to registered handlers.

Member Function Documentation

◆ register_handler()

void Router::register_handler ( MessageType  type,
std::function< void(const Message &)>  handler 
)

Registers a handler for a specific message type. If the handler already exists, it will be overwritten.

◆ route()

void Router::route ( const Message msg) const

Routes the message to its corresponding handler. If no handler exists, the message is ignored.

◆ unregister_handler()

void Router::unregister_handler ( MessageType  type)

Unregisters the handler associated with a message type.

Exceptions
std::runtime_errorif no handler exists.

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