|
ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
|
家族/公会系统 Actor More...
#include <actor_family.h>
Public Types | |
| using | handle_cmd = tools::cmd<actor_mail, std::string, int, ncjson&> |
| Public Types inherited from ngl::actor_base | |
| template<typename ... ARG> | |
| using | create_fun = std::function<std::shared_ptr<actor_base>(i16_area, i32_actordataid, ARG...)> |
Public Member Functions | |
| virtual | ~actor_family ()=default |
| 析构函数 | |
| virtual void | init () |
| 初始化,绑定数据库组件并加载玩家简要数据 | |
| virtual void | erase_actor_before () |
| Actor 销毁前回调,退出 NSP 简要数据实例和掉落系统 | |
| virtual void | loaddb_finish (pbdb::ENUM_DB atype, enum_dbstat astat) |
| 数据库加载完成回调,注册玩家登录和下线事件处理函数 | |
| drop< actor_family > & | get_drop () |
| 获取掉落系统引用 | |
| bool | handle (const message< mforward< np_gm > > &adata) |
| 处理 GM 命令 | |
| bool | handle (const message< mforward< pbnet::PROBUFF_NET_FAMIL_CEDE > > &adata) |
| 处理公会转让请求 | |
| bool | handle (const message< mforward< pbnet::PROBUFF_NET_FAMIL_CHANGENAME > > &adata) |
| 处理公会改名请求 | |
| bool | handle (const message< mforward< pbnet::PROBUFF_NET_FAMIL_CREATE > > &adata) |
| 处理创建公会请求 | |
| bool | handle (const message< mforward< pbnet::PROBUFF_NET_FAMIL_INFO > > &adata) |
| 处理公会信息查询请求 | |
| bool | handle (const message< mforward< pbnet::PROBUFF_NET_FAMIL_JOIN > > &adata) |
| 处理加入/取消申请公会请求 | |
| bool | handle (const message< mforward< pbnet::PROBUFF_NET_FAMIL_LEAVE > > &adata) |
| 处理退出公会请求 | |
| bool | handle (const message< mforward< pbnet::PROBUFF_NET_FAMIL_LIST > > &adata) |
| 处理公会列表查询请求 | |
| bool | handle (const message< mforward< pbnet::PROBUFF_NET_FAMIL_RATIFY_JOIN > > &adata) |
| 处理批准/拒绝加入公会申请请求 | |
| bool | handle (const message< mforward< pbnet::PROBUFF_NET_FAMIL_SIGN > > &adata) |
| 处理公会签到请求 | |
| bool | handle (const message< np_eevents_logic_rolelogin > &adata) |
| 处理玩家登录事件,通知公会其他成员 | |
| bool | handle (const message< np_eevents_logic_roleoffline > &adata) |
| 处理玩家下线事件,通知公会其他成员 | |
| Public Member Functions inherited from ngl::actor | |
| template<typename TDerived> | |
| void | init_rfun () |
| 初始化消息分发器。 | |
| actor (const actorparm &aparm) | |
| 构造函数。 | |
| actor_stat | activity_stat () final |
| 获取调度器可见的生命周期状态。 | |
| void | set_activity_stat (actor_stat astat) final |
| 更新调度器可见的生命周期状态。 | |
| void | release () final |
| 停止actor,排空队列中的工作,并持久化DB支持的状态。 | |
| bool | list_empty () final |
| 检查普通队列和优先级队列是否都为空。 | |
| bool | pending_empty () final |
| 检查高优先级队列是否为空 | |
| bool | high_empty () final |
| 检查优先级队列是否为空。 | |
| std::optional< int32_t > | hight_value () |
| 获取当前最高优先级值。 | |
| bool | push (handle_pram &apram) final |
| 将传入任务入队到相应的优先级队列。 | |
| bool | actor_handle (i32_threadid athreadid) final |
| 在指定的工作线程上运行一个调度切片。 | |
| template<typename T> | |
| bool | ahandle (const std::shared_ptr< T > &aparm) |
| 处理类型化消息。 | |
| bool | ahandle (i32_threadid athreadid, handle_pram &aparm) |
| 处理消息队列中的消息。 | |
| virtual void | broadcast () |
| 广播消息处理钩子。 | |
| bool | handle_broadcast (const message< np_actor_broadcast > &adata) |
| 合成广播消息的内部入口点。 | |
| bool | handle_close (const message< np_actor_close > &) |
| 合成关闭消息的内部入口点。 | |
| template<typename TMESSAGE> | |
| bool | handle_script (const message< TMESSAGE > &adata) |
| 将类型化消息转发到附加的脚本运行时。 | |
| Public Member Functions inherited from ngl::actor_base | |
| actor_base (const actorparmbase &aparm) | |
| Actor基类构造函数 | |
| nready & | ready () |
| std::unique_ptr< nmanage_dbclient > & | manage_dbclient () |
| void | set_db_component (ndb_component *acomponent) |
| void | db_component_init_data () |
| void | init_db_component (bool acreate) |
| void | add_dbclient (ndbclient_base *adbclient, i64_actorid aid) |
| template<pbdb::ENUM_DB DBTYPE, typename TDBTAB, typename TACTOR> | |
| bool | handle_db (const message< np_actordb_load_response< DBTYPE, TDBTAB > > &adata) |
| virtual void | handle_after (handle_pram &) |
| virtual void | save () |
| bool | is_single () const |
| const nguid & | guid () const |
| i64_actorid | id_guid () const |
| i32_actordataid | id () const |
| i16_area | area () const |
| ENUM_ACTOR | type () const |
| virtual void | erase_actor () |
| 从actor_manage中注销并销毁此Actor | |
| bool | nscript_using () const |
| bool | nscript_db_loadfinish () const |
| template<typename T> | |
| bool | nscript_data_push (const char *asource, const T &adata, bool aedit) |
| template<typename T> | |
| bool | nscript_data_del (int64_t adataid) |
| template<typename T> | |
| bool | nscript_data_checkout (int64_t adataid, T &adata) |
| template<typename T> | |
| bool | nscript_data_checkout (std::map< int64_t, T > &adata) |
| template<typename T> | |
| bool | nscript_data_checkdel (int64_t adataid) |
| template<typename T> | |
| bool | nscript_data_checkdel (std::vector< int64_t > &adeldata) |
| template<typename T> | |
| bool | nscript_handle (const T &adata) |
| void | kcp_setindex (i32_serverid aserverid, pbnet::ENUM_KCP aenum, i16_port akcpindex) |
| std::optional< i16_port > | kcp_index (i32_serverid aserverid, pbnet::ENUM_KCP aenum) |
| std::optional< i16_port > | kcp_index (int16_t aservertid, int16_t atcount, pbnet::ENUM_KCP aenum) |
| bool | kcp_connect (i16_port auport, const std::string &aip, i16_port aprot, i64_actorid aactoridserver, std::string &akcpsession) const |
| int64_t | set_timer (const np_timerparm &aparm) |
| 为当前Actor设置定时器 | |
| bool | isbroadcast () const |
| void | set_broadcast (bool aisbroadcast) |
| template<typename T> | |
| void | handle_print (const message< T > &adata) const |
Static Public Member Functions | |
| static void | create () |
| 创建 Actor 单例实例 | |
| static ENUM_ACTOR | actor_type () |
| 返回 Actor 类型 ACTOR_FAMILY | |
| static i64_actorid | actorid () |
| 生成 Actor 唯一 ID,基于类型和合并区域 | |
| static void | nregister () |
| 注册定时器和消息处理器 | |
| Static Public Member Functions inherited from ngl::actor | |
| template<typename TDerived> | |
| static void | register_timer (Tfun< TDerived, np_timerparm > afun=&TDerived::timer_handle) |
| 注册定时器回调函数。 | |
| template<typename TDerived, typename T> | |
| static void | register_actor_s (const std::function< void(TDerived *, const message< T > &)> &afun) |
| 注册基于std::function的消息处理器。 | |
| template<typename TDerived, typename ... ARG> | |
| static void | register_actor (ARG... afun) |
| 注册一个或多个强类型消息处理器。 | |
| template<typename TDerived, typename T> | |
| static void | register_actornonet (const Tfun< TDerived, T > afun) |
| 注册本地专用消息处理器(不来自网络协议分发)。 | |
| template<typename TDerived, typename ... ARG> | |
| static void | register_handle () |
| 注册TDerived::handle作为消息处理器。 | |
| template<typename TDerived, typename ... ARG> | |
| static void | register_script_handle () |
| 注册脚本支持的消息处理器。 | |
| template<typename TDerived, typename ... ARG> | |
| static void | register_forward_c2g () |
| 注册客户端到网关的转发处理器。 | |
| template<typename TDerived, typename ... ARG> | |
| static void | register_forward_g2c () |
| 注册网关到客户端的转发处理器。 | |
| template<typename TDerived, ENUM_ACTOR ACTOR, typename ... ARG> | |
| static void | register_secondary_forward_c2g () |
| 注册中继actor的二级转发辅助器。 | |
| Static Public Member Functions inherited from ngl::actor_base | |
| static void | erase_actor (const nguid &aguid) |
| static std::shared_ptr< pack > | jsonpack (const std::string &apbname, const std::string &ajson, i64_actorid aactorid, i64_actorid arequestactorid, bool ahead=false) |
| template<typename T> | |
| static std::shared_ptr< pack > | net_pack (T &adata, i64_actorid aactorid, i64_actorid arequestactorid, bool ahead=false) |
| static bool | send_pack (i32_sessionid asession, std::shared_ptr< pack > &apack) |
| template<typename T> | |
| static bool | send (i32_sessionid asession, const T &adata, i64_actorid aactorid, i64_actorid arequestactorid) |
| template<typename T> | |
| static bool | send_server (i32_serverid aserverid, const T &adata, i64_actorid aactorid, i64_actorid arequestactorid) |
| template<typename T> | |
| static bool | send_server (const std::set< i32_serverid > &aserverids, const T &adata, i64_actorid aactorid, i64_actorid arequestactorid) |
| static bool | send_server (i32_serverid aserverid, std::shared_ptr< pack > &apack) |
| static bool | kcp_sendpack (i64_actorid aactorid, std::shared_ptr< pack > &adata, i16_port auport=0) |
| static bool | kcp_sendpack (const std::set< i64_actorid > &aactorids, std::shared_ptr< pack > &adata, i16_port auport=0) |
| template<typename T> | |
| static bool | kcp_send (i64_actorid aactorid, const T &adata, i16_port auport=0) |
| 向单个Actor发送KCP数据(actor_base模板实现)。 | |
| template<typename T> | |
| static bool | kcp_send (const std::set< i64_actorid > &aactorids, const T &adata, i16_port auport=0) |
| 向一组Actor广播KCP数据(actor_base模板实现)。 | |
| static i64_actorid | actorclient_guid () |
| template<typename T> | |
| static void | send_client (const std::set< i64_actorid > &aids, const T &adata, ENET_PROTOCOL aprotocol=ENET_TCP) |
| template<typename T> | |
| static void | send_client (i64_actorid aid, const T &adata, ENET_PROTOCOL aprotocol=ENET_TCP) |
| template<typename T> | |
| static void | send_client (const std::vector< i64_actorid > &aids, const T &adata, ENET_PROTOCOL aprotocol=ENET_TCP) |
| template<typename T> | |
| static void | send_client (const T &adata, ENET_PROTOCOL aprotocol=ENET_TCP) |
| template<typename T> | |
| static void | send_clientbyarea (i16_area aarea, const T &adata, ENET_PROTOCOL aprotocol=ENET_TCP) |
| static void | send_actor (const nguid &aguid, const std::shared_ptr< pack > &adata) |
| 向指定Actor发送消息包 | |
| template<typename T, bool IS_SEND = true> | |
| static void | send_actor (ENUM_ACTOR atype, const std::shared_ptr< T > &adata) |
| template<typename T, bool IS_SEND = true> | |
| static void | send_actor (const nguid &aguid, const nguid &arequestguid, const std::shared_ptr< T > &adata) |
| template<typename T, bool IS_SEND = true> | |
| static void | send_actor (const nguid &aguid, const nguid &arequestguid, const std::shared_ptr< T > &adata, const std::function< void()> &afailfun) |
| template<typename T, bool IS_SEND = true> | |
| static void | send_actor (const std::set< i64_actorid > &asetguid, const nguid &arequestguid, const std::shared_ptr< T > &adata) |
| static void | start_broadcast () |
| 启动全局广播定时器 | |
| template<typename TDerived> | |
| static void | first_nregister (ENUM_ACTOR atype) |
| template<typename TACTOR, typename ... ARG> | |
| static std::shared_ptr< actor_base > | create (i16_area aarea, i32_actordataid aid, ARG &&... args) |
| actor工厂方法(编译期类型) | |
| template<typename ... ARG> | |
| static std::map< ENUM_ACTOR, create_fun< ARG... > > & | creators () |
| template<ENUM_ACTOR EACTOR, typename TACTOR, typename ... ARG> | |
| static void | cregister () |
| template<typename ... ARG> | |
| static std::shared_ptr< actor_base > | create (ENUM_ACTOR atype, i16_area aarea, i32_actordataid aid, ARG &&... args) |
| actor工厂方法(运行时类型,查分桶表转调编译期create<TACTOR>) | |
Friends | |
| class | familyer |
| class | family |
| class | actor_instance< actor_family > |
家族/公会系统 Actor
管理游戏中的家族/公会系统,包括创建、加入、退出、转让等操作。 使用数据库组件 m_familyer(玩家-家族映射)和 m_family(家族数据)进行数据持久化。
主要功能:
Actor 类型: ACTOR_FAMILY(单例,广播模式) 权重: 0x7fffffff(最高优先级)
|
virtual |
Actor 销毁前回调,退出 NSP 简要数据实例和掉落系统
Reimplemented from ngl::actor_base.
|
virtual |
初始化,绑定数据库组件并加载玩家简要数据
Reimplemented from ngl::actor_base.
|
virtual |
数据库加载完成回调,注册玩家登录和下线事件处理函数
Reimplemented from ngl::actor_base.