--[[ Descripttion:玩家信息 version: Author: Neo,Huang Date: 2022-05-26 19:45:58 LastEditors: Neo,Huang LastEditTime: 2022-05-26 19:46:41 --]] local moduleData = require("data.module") local lib_game_redis = require("lib_game_redis") local root = {} -- 新增在线人数 function root:add_online_count(uid) if is_empty(uid) or is_robot(uid) then return false end local channel = moduleData:get_channel(uid) local bandShareCode = moduleData:hget(uid, "user", "bandShareCode") local key = "online:count" -- 全服人数 lib_game_redis:hincrby(key, "all", 1) -- 渠道 if not is_empty(channel) then lib_game_redis:hincrby(key, string.format("channel:%s", tostring(channel)), 1) end -- 主播 if not is_empty(bandShareCode) then lib_game_redis:hincrby(key, string.format("bandShareCode:%s", tostring(bandShareCode)), 1) end end -- 减少在线人数 function root:sub_online_count(uid) if is_empty(uid) or is_robot(uid) then return false end local channel = moduleData:get_channel(uid) local bandShareCode = moduleData:hget(uid, "user", "bandShareCode") local key = "online:count" -- 全服人数 lib_game_redis:hincrby(key, "all", -1) -- 渠道 if not is_empty(channel) then lib_game_redis:hincrby(key, string.format("channel:%s", tostring(channel)), -1) end -- 主播 if not is_empty(bandShareCode) then lib_game_redis:hincrby(key, string.format("bandShareCode:%s", tostring(bandShareCode)), -1) end end return root