gamebase
简介
一个通用的游戏服基础模块
组件接口
FDbase.gs
数据字典
FEventEmitter.gs
事件触发器
函数原型 | 函数作用 |
---|---|
void on(string event, function fn) | 关注指定事件 |
void on_raw(string event, function fn) | 关注指定事件,回调直接传array,不展开参数 |
void once(string event, function fn) | 关注一次指定事件(执行后删除) |
void remove_event(string event) | 取消指定事件 |
void emit(string event, ...) | 触发事件 |
void emit_local(string event, ...) | 触发事件(local版,确定不跨域) |
void remove_listener(string event, function fn) | 根据function移除指定的监听 |
void remove_listener_by_object(string event, object func_ob) | 根据function对应的object移除某个事件的监听 |
void remove_listeners_by_object(object func_ob) | 把指定对象注册过的所有事件监听删除(开销略大,慎用) |
map debug_get_events() | 调试方法,获取所有注册的时间 |
FFields.gs
字段同步
函数原型 | 函数作用 |
---|---|
void set_field_sync(mixed field, bool is_sync) | 设置字段是否可以同步 |
void set_fields_sync(map fields) | 设置一组字段是否可以同步 |
bool is_fields_sync(mixed field) | 是否需要同步该字段 |
function get_field_update_func() | 获取字段更新方法 |
void set_field_update_func(function func) | 设置字段更新方法 |
mixed query(string key) | 查询接口覆写,可以查询配置数据 |
void set(string key, mixed val, bool is_force_sync) | 设置键值对,可以判断是否同步 |
void dict_set(mixed d, mixed key, mixed val) | 字典值设置 |
void delete(string key) | 删除字段 |
void dict_delete(mixed d, mixed key) | 删除字典字段 |
void field_update(string d, mixed key, mixed val) | 字段更新 |
FNode.gs
节点组件
FService.gs
服务组件
函数原型 | 函数作用 |
---|---|
void set_option(map option) | 设置选项 |
void check_queue() | 队列的自检 |
mixed process_sync(function func, float timeout, bool timeout_error) | 同步处理方法 |
void process_async(function func, function callback) | 异步处理 |
FieldsD.gs
字段管理
函数原型 | 函数作用 |
---|---|
map get_fields() | 获取所有字段信息 |
void set_field_sync(string type, mixed field, bool is_sync) | 设置字段是否可以同步 |
void set_fields_sync(string type, map fields_list) | 设置一组字段是否可以同步 |
bool is_fields_sync(string type, mixed field) | 是否需要同步该字段 |
LogD.gs
日志模块
函数原型 | 函数作用 |
---|---|
void log(string rid, string op, mixed v1, mixed v2, mixed v3, mixed v4, mixed misc) | 异步(顺序)记录日志 |
RidD.gs
管理所有拥有Rid的对象实例,并提供全局注册查找的API
函数原型 | 函数作用 |
---|---|
string new_rid(string prefix) | 创建新的rid |
void add_object(object ob) | 增加对象 |
void remove_object(object ob) | 移除对象 |
object find_object_by_rid(string rid) | 根据rid查找对象 |
map get_all_objects() | 获取所有对象 |
VersionD.gs
版本校验
函数原型 | 函数作用 |
---|---|
bool check_version(string client_version) | 检测服务器版本 |