From 77014b19540aae6ebd94d7d7ec54bc75baa03a1a Mon Sep 17 00:00:00 2001 From: zqj <582132116@qq.com> Date: Tue, 14 Sep 2021 15:08:55 +0800 Subject: [PATCH] fix: 新设备全局唯一,deviceId存储在center_server 中的 center_device字段中 --- src/actions/RoleAction.lua | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/actions/RoleAction.lua b/src/actions/RoleAction.lua index 814945e..9c1ca80 100644 --- a/src/actions/RoleAction.lua +++ b/src/actions/RoleAction.lua @@ -83,9 +83,6 @@ function _M.loginRpc( agent, data ) end end - -- 设备记录 - redisproxy:sadd(string_format("device:%d", roleId), msg.device) - local now = skynet.timex() local role = agent.role -- 2 @@ -338,8 +335,14 @@ function _M.loginRpc( agent, data ) local hangPass = role:getProperty("hangPass") role:mylog("login", {key1 = agent.ip:toArray(false, ":")[1], int1 = hangPass[1] or 0}) - if msg.newdevice then - role:mylog("newdevice", {key1 = agent.ip:toArray(false, ":")[1]}) + + -- 是否是新设备 + local deviced = cluster.query("center", "deviced") + if deviced then + local status, back = pcall(cluster.call, "center", deviced, "isNewDevice", {device = msg.device}) + if status and back then + role:mylog("newdevice", {key1 = agent.ip:toArray(false, ":")[1]}) + end end return true -- libgit2 0.21.2