ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
ngl::protocol Class Reference

协议处理和分发核心类。 More...

#include <protocol.h>

Public Types

using fun_pack = std::function<std::shared_ptr<void>(std::shared_ptr<pack>&)>
 从pack反序列化为类型化载荷的函数类型
using fun_run = std::function<bool(std::shared_ptr<pack>&, std::shared_ptr<void>&)>
 协议处理函数类型

Static Public Member Functions

static pfun * find (i32_protocolnum aprotocol)
 查找一个已注册的协议条目。
static const char * name (i32_protocolnum aprotocol)
 获取协议的显示名称。
static void print (const char *amsg, i32_protocolnum aprotocol)
 打印协议信息到日志。
static void registers (int aprotocol, ENUM_ACTOR aenumactor, const protocol::fun_pack &apackfun, const protocol::fun_run &arunfun, const char *aname)
 为一个actor类型注册一个协议ID。
static void push (std::shared_ptr< pack > &apack)
 解码网络包并路由到匹配的actor分发器。
template<typename T>
static void registry_actor (ENUM_ACTOR atype, const char *aname)
template<typename T>
static void registry_c2g (ENUM_ACTOR atype, int32_t aprotocolnum, const char *aname)
template<typename T>
static void registry_g2c (ENUM_ACTOR atype, int32_t aprotocolnum, const char *aname)
template<typename T>
static void registry_mass (int32_t aprotocolnum, const char *aname)

Detailed Description

协议处理和分发核心类。

管理协议处理函数的注册、查找和分发,提供协议消息的路由功能。 采用单例模式,通过静态方法访问协议注册表。

Member Function Documentation

◆ find()

protocol::pfun * ngl::protocol::find ( i32_protocolnum aprotocol)
static

查找一个已注册的协议条目。

Parameters
aprotocol协议ID。
Returns
协议条目指针,未找到返回nullptr。

◆ name()

const char * ngl::protocol::name ( i32_protocolnum aprotocol)
static

获取协议的显示名称。

Parameters
aprotocol协议ID。
Returns
协议名称字符串。

◆ print()

void ngl::protocol::print ( const char * amsg,
i32_protocolnum aprotocol )
static

打印协议信息到日志。

Parameters
amsg前缀消息。
aprotocol协议ID。

◆ push()

void ngl::protocol::push ( std::shared_ptr< pack > & apack)
static

解码网络包并路由到匹配的actor分发器。

Parameters
apack网络数据包。

◆ registers()

void ngl::protocol::registers ( int aprotocol,
ENUM_ACTOR aenumactor,
const protocol::fun_pack & apackfun,
const protocol::fun_run & arunfun,
const char * aname )
static

为一个actor类型注册一个协议ID。

Parameters
aprotocol协议ID。
aenumactorActor类型枚举。
apackfun反序列化函数。
arunfun处理函数。
aname协议名称(用于调试)。

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