Commit 77014b19540aae6ebd94d7d7ec54bc75baa03a1a

Authored by zhangqijia
1 parent 1632e6ed

fix: 新设备全局唯一,deviceId存储在center_server 中的 center_device字段中

Showing 1 changed file with 8 additions and 5 deletions   Show diff stats
src/actions/RoleAction.lua
... ... @@ -83,9 +83,6 @@ function _M.loginRpc( agent, data )
83 83 end
84 84 end
85 85  
86   - -- 设备记录
87   - redisproxy:sadd(string_format("device:%d", roleId), msg.device)
88   -
89 86 local now = skynet.timex()
90 87 local role = agent.role
91 88 -- 2
... ... @@ -338,8 +335,14 @@ function _M.loginRpc( agent, data )
338 335  
339 336 local hangPass = role:getProperty("hangPass")
340 337 role:mylog("login", {key1 = agent.ip:toArray(false, ":")[1], int1 = hangPass[1] or 0})
341   - if msg.newdevice then
342   - role:mylog("newdevice", {key1 = agent.ip:toArray(false, ":")[1]})
  338 +
  339 + -- 是否是新设备
  340 + local deviced = cluster.query("center", "deviced")
  341 + if deviced then
  342 + local status, back = pcall(cluster.call, "center", deviced, "isNewDevice", {device = msg.device})
  343 + if status and back then
  344 + role:mylog("newdevice", {key1 = agent.ip:toArray(false, ":")[1]})
  345 + end
343 346 end
344 347  
345 348 return true
... ...