social_server
简介
以pkg形式发布的社交服务器
组件接口
common.gs
社交服主模块的入口文件
提供主模块的初始化和关闭接口
| 函数原型 | 函数作用 |
|---|---|
| string get_native_path() | 获取本地扩展的路径 |
| string get_native_boot_file() | 获取本地扩展的启动文件 |
| void boot() | 主模块的启动接口 |
| void shutdown() | 主模块的关闭接口 |
AccountD.gs
账号模块
| 函数原型 | 函数作用 |
|---|---|
| object assure_connection() | 获取和账号数据库的客户端连接对象 |
| map read_account(string account) | 获取账号基础资料 |
| bool create_account(string account, map dbase) | 创建账号基础资料 |
| bool update_account_field(string account, string field, mixed value) | 更新账号基础资料字段 |
| bool destroy_account(string account) | 删除账号基础资料 |
AuthD.gs
账号认证模块
| 函数原型 | 函数作用 |
|---|---|
| map auth(string account, map args = ) | 账号认证 |
| bool internal_auth(string token) | 内部连接认证(只需要验证令牌值) |
| bool set_auth_agent(string name, map agent_info) | 设置服务器使用的认证代理 |
| map find_auth_agent(string name) | 查找服务器的认证代理 |
ChatD.gs
聊天模块
ChatMonitorD.gs
聊天监控功能模块
DelayD.gs
提供延迟执行操作的功能模块
| 函数原型 | 函数作用 |
|---|---|
| void delay_invoke(float seconds, function fn) | 延迟指定时长执行函数 |
EtcdClientD.gs
etcd server监听模块,仅在[etcd_server]设置时起效
FriendD.gs
好友功能模块
| 函数原型 | 函数作用 |
|---|---|
| object assure_connection(string server_id) | 获取指定服务器名称的好友数据库的客户端连接对象 |
| void set_list_friend_ids(object user, array friend_ids) | 记录已经获取的好友id列表 |
| void delete_list_friend_ids(object user, array friend_ids) | 删除已经获取的好友id列表 |
| array get_list_friend_ids(object user) | 获取已经获取的好友id列表 |
| void set_list_blacklist(object user, array blacklist) | 记录已经获取的黑名单id列表 |
| void delete_list_blacklist(object user, array blacklist) | 删除已经获取的黑名单id列表 |
| array get_list_blacklist(object user) | 获取已经获取的黑名单id列表 |
| void set_list_reqs(object user, array reqs) | 记录已经获取的好友请求列表 |
| void delete_list_reqs(object user, array reqs) | 删除已经获取的好友请求列表 |
| array get_list_reqs(object user) | 获取已经获取的好友请求列表 |
InternalD.gs
社交服之间互联功能模块
etcd server模 式下:
社交服之间不互连,仅通过etcd server进行消息同步
不需要获取其它社交服务器的列表
只支持广播: 通过内部连接给特定的某个社交服发送消息是没有意义的
社交服务器列表的获取:
-
来自notify_server的推送
-
定时更新
| 函数原型 | 函数作用 |
|---|---|
| void set_servers(map servers) | 增量设置社交服务器信息列表 |
| void sync_and_invoke_local(string op, ...) | 本地执行操作并且同步操作给其他社交服务器 |
| void sync(string op, ...) | 同步操作给其他社交服务器 |
| void assure_clients(array ids) | 确保和其它社交服务器的连接(连接不存在则创建) |
| void close_clients(array ids) | 关闭到其它社交服务器的连接 |
| void create_clients(array ids) | 创建到其它社交服务器的连接 |
MailD.gs
邮件功能模块
| 函数原型 | 函数作用 |
|---|---|
| object assure_connection(string server_id) | 获取指定的服务器名称的 邮件数据库的客户端连接 |
| string get_sys_mailbox_id(string server_id) | 获取指定的服务器名称的系统邮箱id |
| string get_sys_sender() | 获取系统邮件的发送者 |
| map pull_mail_list(object user, int count = 10) | 拖取邮件列表(从上一次的位置继续拖取) |
MomentD.gs
朋友圈功能模块
| 函数原型 | 函数作用 |
|---|---|
| object assure_connection(string server_id) | 获取指定服务器名称的朋友圈数据库的客户端连接 |
| int get_last_recv_moment_id(object user, string target) | 获取最近一次记录的目标账号的朋友圈id |
| void set_last_recv_moment_id(object user, string target, int moment_id) | 记录最近一次的目标账号的朋友圈id |
| int get_last_recv_moment_comment_id(object user, int moment_id) | 获取最近一次记录的朋友圈评论id |
| void set_last_recv_moment_comment_id(object user, int moment_id, int cmoment_id) | 记录最 近一次的朋友圈评论id |
| map pull_moment_list(object user, string target, int count = 10) | 拖取指定目标账号的朋友圈列表(从上一次拖取的位置继续拖取) |
| bool upload_photo_buff(object user, int photo_id, buffer photo_part_buff, map para = ) | 上传照片 |
| map fetch_photo_buff(object user, int photo_id, map para = ) | 获取图片二进制内容 |
NotifyClientD.gs
作为客户端对接通知服务器的功能模块
| 函数原型 | 函数作用 |
|---|---|
| bool is_self_notify_enabled() | 是否启动本机消息推送 |
| map get_all_servers() | 获取通知服务器的所有用户列表 |
| void notify(string server_id, mixed name_or_names, map args = ) | 向指定服务器id和指定的账户列表发送通知消息 |
| void push(string event, map info = ) | 向通知服务器发送推送消息 |
SwordD.gs
敏感词功能模块
一共有四种方式可以屏蔽敏感词,同时只有一种方式起效
方式一:接入最新的雷霆内容安全平台(基于pkt.leiting.sword)
方式二:接入老的雷霆内容安全平台(基于pkt.lt_sword)
方式三:接入敏感词服务器(基于pkg.sword_client)
方式四:接入本地敏感词功能模块(基于pkg.ssword)
可以通过配置[screen_all_sword]配置关闭全部敏感词功能
| 函数原型 | 函数作用 |
|---|---|
| array filter_content(map msg) | 内容过滤 |
| void set_game_code_and_key(string game_code, string key) | 设置雷霆内容安全平台游戏码和签名密钥 |
| map patrol_init(map msg) | 生成一个巡服上报消息实例 |
| void patrol_set_field(map m, string key, mixed val) | 设置巡服上报键值 |
| void patrol(map m, function func) | 执行巡服上报 |
SyncOpD.gs
响应通知服务器的同步操作通知的功能模块
| 函数原型 | 函数作用 |
|---|---|
| void invoke(string op, ...) | 执行一个同步操作 |
SystemD.gs
系统功能模块
处理系统启动、关闭
| 函数原型 | 函数作用 |
|---|---|
| bool is_shut() | 判断系统是否处于关闭状态 |
| bool is_booting() | 判断系统是否处于启动中状态 |
| bool is_shutting() | 判断系统是否处于关机中状态 |
| bool is_running() | 判断系统是否处于正常运行状态 |
| void boot(function func) | 执行系统启动 |
| void on_post_boot(function func) | 执行系统启动后处理 |
| void shutdown(function func = nil) | 执行系统关机 |
| void on_post_shutdown(function func) | 执行系统关闭后处理 |
UserD.gs
用户对象管理模块
| 函数原型 | 函数作用 |
|---|---|
| void add_user(object u) | 添加用户 |
| void remove_user(object u) | 移除用户 |
| void walk_all_users(function func) | 遍历所有用户对象 |
| void walk_server_users(string server_id, function func) | 遍历指定服务器的所有用户对象 |
| void walk_name_users(mixed name_or_names, function func) | 遍历指定名字的所有用户对象 |
| void walk_server_name_users(string server_id, mixed name_or_names, function func) | 遍历指定服务器和名字的所有用户对象 |
| void debug_on(bool on = true) | 调试接口 - 打开/关闭调试 |
| void dump() | 调试接口 - 输出所有用户对象 |
UserEventD.gs
玩家事件模块
| 函数原型 | 函数作用 |
|---|---|
| void listen_event(string user_event, function func) | 监听玩家事件 |
account_op.gs
账号操作功能模块
账号数据分成两部分,一部分是基础资料(静态数据),轻易不更新
另一部分是账号动态资料(动态数据,也需要序列化),可能经常更新
这样做的目的是基础资料的缓存不必频繁更新
arg_protocol.gs
客户端命令接口参数协议模块
只有在配置表中配置了参数协议时起效
| 函数原型 | 函数作用 |
|---|---|
| mixed get_cmd_arg_protocol_config(string cmd) | 获取指令的参数协议配置 |
| void set_cmd_arg_protocol(string cmd, CmdArgProtocol protocol) | 设置指令的参数协议 |
| mixed get_cmd_arg_protocol(string cmd) | 获取网络指令的参数协议 |
| bool match_cmd_arg_protocol(string cmd, ...) | 检查网络指令的参数是否匹配 |
| CmdArgProtocol new_cmd_arg_protocol(mixed value) | 创建一个CmdArgProtocol实例 |
| void dump(string cmd = nil) | 调试接口 - 输出指令的参数协议 |
auth_op.gs
验证操作的功能模块
| 函数原型 | 函数作用 |
|---|---|
| bool set_auth_agent(object conn, string name, map info) | 设置服务器对应的账号验证代理 |
| map find_auth_agent(object conn, string name) | 获取指定服务器名称对应的账号验证代理 |
| object assure_auth_agent_cache(string name, object conn) | 获取服务器对应的账号验证代理缓存对象 |
caches.gs
对象缓存池
为了减少数据库访问频率,将一些经常访问的数据缓存起来
本模块是这些缓存对象的管理器,提供对象的创建和销毁接口
| 函数原型 | 函数作用 |
|---|---|
| object get_cache(string type, string key) | 获取缓存对象 |
| object create_cache(string type, string key, ...) | 创建缓存对象 |
| void close_cache(string type, string key) | 关闭缓存对象 |
| void close_caches_by_type(string type) | 关闭指定类型的所有缓存对象 |
| void close_all_caches() | 关闭所有缓存对象 |
| void dump() | 调试接口 - 输出所有的缓存对象调试信息 |
chatroom.gs
聊天室相关操作
chat_op.gs
聊天操作功能模块
config.gs
社交服配置模块
社交服的配置可以通过启动参数中添加/D CONFIG 来指定配置文件;如果未指定配置文件,则默认使用/etc/config.json
| 函数原型 | 函数作用 |
|---|---|
| void init(string config_file) | 读取配置文件初始化 |
| mixed get(string path) | 获取配置值 |
| string system_id() | 获取系统id |
| string ip() | 获取本机ip |
| int port() | 获取本机端口 |
friend_op.gs
好友操作功能模块
InternalClient.gs
社交服之间的内部连接会话对象
| 函数原型 | 函数作用 |
|---|---|
| bool ping() | 测试连接状态 |
internal_client.gs
提供社交服之间的内部连接的功能模块
| 函数原型 | 函数作用 |
|---|---|
| object create_client(map para) | 创建一个内部客户端会话对象 |
mailbox.gs
邮箱相关操作
mail_op.gs
邮件操作功能模块
moment_op.gs
提供朋友圈操作的功能模块