123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- local logger = require "logger"
- local redisdriver = require "skynet.db.redis"
- local stringify = require "stringify"
- local skynet = require "skynet"
- local queue = require "skynet.queue"
- local synchronized = queue()
- local trace = logger.trace
- local redis
- local redis_recharge
- local start
- local rechargeser
- local REBATE = "rebate:"
- local KEYGEN_PAY = "%s:%s"
- local authz = {
- lee = "yytx-Games-9527"
- }
- local function start_pay()
- local conf = assert(option.redis)
- redis = redisdriver.connect(conf)
- redis_recharge = redisdriver.connect(conf)
- redis:select(0)
- redis_recharge:select(3)
- rechargeser = rechargeser or skynet.localname(".recharge")
- return 1
- end
- local facebook = nil
- local function retrieve_facebook_account(account, sid, channel)
- facebook = facebook or skynet.localname(".facebook")
- local errno, fb = skynet.call(facebook, "lua", "retrieve", account, channel)
- local uid = nil
- if errno == 200 then
- uid = redis:get(string.format("account:%s:%s:%s", channel, sid, fb))
- end
- return errno, uid
- end
- local get_server_uid = function(args, ipaddr)
- return synchronized(function()
- start = start or start_pay()
- trace("处理来自主机 %s 的uid检测请求", ipaddr)
- local channel = args.channel
- local account = args.account
- local serverid = tonumber(args.serverid)
- trace("开始处理uid检测信息:%s",stringify(args))
-
- local user = args.user or ""
- local pwd = args.pwd or ""
- if authz[user] ~= pwd then
- return { code=2 }
- end
- if not account or not channel then
- return { code=1 }
- end
- local uid
- if account then
- local k = string.format("account:%s:%s:%s", channel, serverid, account)
- uid = redis:get(k)
- end
- if not uid then
- local errno, val = retrieve_facebook_account(account, serverid, channel)
- if errno == 200 then
- uid = val
- end
- end
- if not uid then
- trace("验证玩家建号数据错误:setuid:%s, uid:%s",setuid, uid)
- return { code=3 }
- end
- local name
- local level
- if uid then
- local k = string.format("character:%s", uid)
- if redis:hget(k,"sex") then
- name = redis:hget(k,"nickname")
- level = redis:hget(k,"level")
- else
- return { code=3 }
- end
- end
- return { code=0,uid=uid,name=name,level=level }
- end)
- end
- return get_server_uid
|