|
ngl_server 1.0
基于 Actor 模型的 C++ 服务器框架
|
KCP会话管理类。 More...
#include <kcp_session.h>
Public Types | |
| enum | { ekcp_update_intervalms = 10 } |
| KCP配置常量枚举。 More... | |
Public Member Functions | |
| kcp_session (asio_kcp *asiokcp) | |
| 构造函数。 | |
| std::shared_ptr< kcp_endpoint > | add_kcp_endpoint (int32_t aconv, const char *aip, i16_port aport, i64_actorid aactoridserver, i64_actorid aactoridclient) |
| 通过IP和端口添加KCP端点。 | |
| std::shared_ptr< kcp_endpoint > | add (int32_t aconv, const basio::ip::udp::endpoint &aendpoint, i64_actorid aactoridserver, i64_actorid aactoridclient) |
| 通过UDP端点添加KCP端点。 | |
| std::shared_ptr< kcp_endpoint > | reset_add (int32_t aconv, const basio::ip::udp::endpoint &aendpoint, i64_actorid aactoridserver, i64_actorid aactoridclient) |
| 重置并添加KCP端点(用于重连)。 | |
| void | erasebysession (i32_sessionid asession) |
| 根据会话ID移除KCP端点。 | |
| void | erasebyaactorid (i64_actorid aactorid) |
| 根据Actor ID移除KCP端点。 | |
| std::shared_ptr< kcp_endpoint > | find (i32_sessionid asession) |
| 根据会话ID查找KCP端点。 | |
| std::shared_ptr< kcp_endpoint > | findbyactorid (i64_actorid aactorid) |
| 根据Actor ID查找KCP端点。 | |
| std::shared_ptr< kcp_endpoint > | find (const basio::ip::udp::endpoint &aendpoint) |
| 根据UDP端点查找KCP端点。 | |
| void | foreach (const std::function< void(std::shared_ptr< kcp_endpoint > &)> &acall) |
| 遍历所有KCP端点。 | |
| void | foreachbyarea (i16_area aarea, const std::function< void(std::shared_ptr< kcp_endpoint > &)> &acall) |
| 按区域遍历KCP端点。 | |
KCP会话管理类。
管理所有KCP端点的创建、销毁和查找,维护多个索引表以支持高效的查询。 主要职责包括:
| ngl::kcp_session::kcp_session | ( | asio_kcp * | asiokcp | ) |
构造函数。
| asiokcp | 所属的asio_kcp传输实例指针 |
| std::shared_ptr< kcp_endpoint > ngl::kcp_session::add | ( | int32_t | aconv, |
| const basio::ip::udp::endpoint & | aendpoint, | ||
| i64_actorid | aactoridserver, | ||
| i64_actorid | aactoridclient ) |
通过UDP端点添加KCP端点。
| aconv | KCP会话标识 |
| aendpoint | UDP端点 |
| aactoridserver | 服务端Actor ID |
| aactoridclient | 客户端Actor ID |
| std::shared_ptr< kcp_endpoint > ngl::kcp_session::add_kcp_endpoint | ( | int32_t | aconv, |
| const char * | aip, | ||
| i16_port | aport, | ||
| i64_actorid | aactoridserver, | ||
| i64_actorid | aactoridclient ) |
通过IP和端口添加KCP端点。
| aconv | KCP会话标识 |
| aip | 远端IP地址 |
| aport | 远端端口号 |
| aactoridserver | 服务端Actor ID |
| aactoridclient | 客户端Actor ID |
| void ngl::kcp_session::erasebyaactorid | ( | i64_actorid | aactorid | ) |
根据Actor ID移除KCP端点。
| aactorid | 要移除的Actor ID |
| void ngl::kcp_session::erasebysession | ( | i32_sessionid | asession | ) |
根据会话ID移除KCP端点。
| asession | 要移除的会话ID |
| std::shared_ptr< kcp_endpoint > ngl::kcp_session::find | ( | const basio::ip::udp::endpoint & | aendpoint | ) |
根据UDP端点查找KCP端点。
| aendpoint | UDP端点 |
| std::shared_ptr< kcp_endpoint > ngl::kcp_session::find | ( | i32_sessionid | asession | ) |
根据会话ID查找KCP端点。
| asession | 会话ID |
| std::shared_ptr< kcp_endpoint > ngl::kcp_session::findbyactorid | ( | i64_actorid | aactorid | ) |
根据Actor ID查找KCP端点。
| aactorid | Actor ID |
| void ngl::kcp_session::foreach | ( | const std::function< void(std::shared_ptr< kcp_endpoint > &)> & | acall | ) |
遍历所有KCP端点。
| acall | 回调函数,接受KCP端点共享指针引用 |
| void ngl::kcp_session::foreachbyarea | ( | i16_area | aarea, |
| const std::function< void(std::shared_ptr< kcp_endpoint > &)> & | acall ) |
按区域遍历KCP端点。
| aarea | 区域ID |
| acall | 回调函数,接受KCP端点共享指针引用 |
| std::shared_ptr< kcp_endpoint > ngl::kcp_session::reset_add | ( | int32_t | aconv, |
| const basio::ip::udp::endpoint & | aendpoint, | ||
| i64_actorid | aactoridserver, | ||
| i64_actorid | aactoridclient ) |
重置并添加KCP端点(用于重连)。
| aconv | KCP会话标识 |
| aendpoint | UDP端点 |
| aactoridserver | 服务端Actor ID |
| aactoridclient | 客户端Actor ID |