跳到主要内容

user_mgr

简介

玩家管理模块

组件接口

LoginD.gs

处理玩家登录登出逻辑

函数原型函数作用
mixed auth(string account, string pass_md5, map auth_args = )进行认证
mixed check_auth(map login_data)检查认证
mixed register_account(string account, string passwd_md5)注册账号
mixed update_account(string account, string passwd_md5)更新账号
mixed remove_account(string account, string passwd_md5)移除账号
bool check_account_exist(string account, string passwd_md5)账号是否存在
object get_or_create_login_ob(object session, string account, string account_id)获取或创建登录对象
object create_login_ob(object session, string account, string account_id)创建登录对象
void do_login_in_co(object login_ob, LoginContext context, function callback = nil)在协程中执行用户登录
int get_logging_in_num()获取正在登录中的人数
void login(object session, map ld)用户登陆
bool logout(object user, function callback)用户登出,登出完毕后给调用回调
object debug_login(object session, string account, string account_id = nil)调试登陆,只要提供账号,返回玩家对象,根据账号查询角色列表,选中一个角色登录
bool wait_until_no_logging_in()等到登录中人数为0

LoginQueueD.gs

登录队列,同时登录人数过多时排队

函数原型函数作用
void enqueue(object login_ob, ...)某个连接开始排队,不等待
void priority_enqueue(object login_ob, LoginContext context, ...)投递优先登录处理请求
void smart_enqueue(LoginRequestBase login_request)投递自定义的处理请求
array dequeue(int seq)离开排队队列
int get_login_queue_size()获取还未处理完的登录请求队列长度
bool wait_until_queue_empty(int timeout = 60)等待队列处理完
void set_debug_login_pending_time(float t)设置调试登录延迟时间

SystemD.gs

系统模块

函数原型函数作用
void shutdown(map info = nil, bool kill_self = true, function shutdown_call = nil)同步关机
bool is_shutting_down()是否正在关机
void set_booting(bool booting)设置正在启动
bool is_booting()是否正在启动
int get_shutdown_cookie()GM关机功能
string get_server_id()获取服务器ID
string get_server_host()获取服务器IP
int get_server_port()获取服务器端口
string get_server_name()获取服务器名
map get_server_info()获取服务器信息

auth.gs

认证模块

函数原型函数作用
mixed register_account(string account, string passwd_md5)注册账号
mixed update_account(string account, string passwd_md5)更新账号
mixed remove_account(string account, string passwd_md5)移除账号
map get_account(string account)根据账号获取账号信息
array debug_get_all_accounts()调试方法:获取所有账号
array check_auth(map auth_data)检查认证(从服务器发来)
mixed auth(string account, string pass_md5, map auth_args = )请求认证(从客户端发来)
bool check_account_exist(string account, string passwd_md5)账号是否存在

ldap.gs

提供ldap的相关接口

函数原型函数作用
bool is_valid_account(string account)账号是否合法
bool exist_account(string account)是否为域账号

Login.gs

登录对象,处理登录过程,支持排队逻辑

函数原型函数作用
bool load_chars_in()载入账号对应的角色列表
array get_char_list()返回所有角色列表
string get_first_char()获取第一个角色
void set_login_seq(int seq)设置登录序号
void notify_login_queue_state(int handled_seq)通知当前登录队列状态(在登录队列中的位置)

User.gs

用户回话对象

函数原型函数作用
object Session.unbind_connection()取消连接绑定
void Session.close_connection()关闭Session连接后自我处理
void on_login_ok()登陆完成执行函数
void drop_me()删除自己
void logout(function callback = nil)登出,真正析构用户对象
void user_log_online_duration(bool flag_clean = true)记录在线时长日志

user_mgr.gs

函数原型函数作用
void check_logout_all_finish(function callback)检测是否已经全部登出完毕
void logout_all_in_co(function callback = nil)在独立co中登出所有玩家
void logout_all(function callback = nil)登出全部玩家,异步方法,全部登出完成后回调callback,有部分玩家处于正在登录状态,但还未登录完毕
void logout_all_sync()同步等待所有玩家登出
bool mark_logging_out_all(bool is_logout)标记是否正在登出全部玩家,本函数只能在当前对象的post队列中调用
bool is_logging_out_all()是否正在登出全部玩家
void save_all_users()保存所有玩家
void add_user(object user)增加用户
void remove_user(object user)移除用户,登出完成后移除
void add_account_user(string account_id, string rid)在一个账号中增加一个在线角色
bool del_account_user(string account_id, string rid)删除一个账号中的在线角色
map get_accounts()获取_accounts列表
array get_account_user_rids(string account_id)获取某个账号中的在线角色rid列表
object get_user(string user_rid)根据账号获取玩家
array get_users()获取所有玩家的账号(不包括远程玩家)
bool lock_user(string user_rid, string lock_reason = "unspecified")锁定某账号用户的登录登出
bool unlock_user(string user_rid)解锁某账号用户的登录登出
bool is_user_locked(string user_rid)某玩家是否被锁定
array is_user_locked_ex(string user_rid)某玩家是否被锁定并且返回被锁定原因(is_user_locked扩展版本)
map get_locking_users()获取锁定用户列表
bool lock_account(string account_id, string lock_reason = "unspecified")锁定账号
bool unlock_account(string account_id)解锁账号
bool is_account_locked(string account_id)账号是否被锁定
array is_account_locked_ex(string account_id)账号是否被锁定并且返回被锁定原因(is_account_locked扩展版本)
void load_user(object user)加载玩家
void unload_user_and_save_async(object user, function callback)卸载玩家,并异步保存
void unload_user(object user)仅卸载玩家,不保存
array delete_user_by_rid(string user_rid, string account_id)标记某个角色被删除
bool is_user_exist_in_db(string user_rid)玩家在数据库中是否存在
mixed load_or_create_user_sync(int class_id, string account, string account_id, mixed client_info, bool is_robot = false, string user_rid = nil)加载或创建玩家,阻塞操作
map list_users()显示所有玩家(仅供调试)
void drop_user(string rid)删除某个玩家,删除前应该要登出
void drop_all()删除所有玩家和道具
void user_login_ok(object user)用户登录成功后的处理
object get_last_login_user()获取最后一个登录的玩家对象(方便调试)
array get_all_users_ob()获取所有玩家对象(不包括跨服玩家)
void disconnect_all_users(string reason = nil)断开所有玩家并且拒绝再进入
void set_max_user_num(int num)设置最大在线人数
void broadcast_all_users(string cmd, ...)广播所有玩家
void iterate_all_users(function func)遍历所有玩家