12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- local skynet = require "skynet"
- local codecache = require "skynet.codecache"
- require "skynet.manager"
- local logger = require "logger"
- local stringify = require "stringify"
- local cjson = require "cjson"
- local assetcenter
- local watchdog
- local authz = {
- yytx = "lee@YY-Games.520",
- lee = "yytx-Games-9527",
- }
- local span_team = skynet.localname(".span_team")
- -- example:
- --[[
- -- 重新加载指定玩家数据
- http://192.168.1.22:9002/team?user=lee&pwd=lee@123&func_local=player&uids=["uid","uid"]
- -- 重新加载指定队伍的数据
- http://192.168.1.22:9002/team?user=lee&pwd=lee@123&func_local=team&teamids=["tmid","tmid"]
- -- 关闭组队功能
- http://192.168.1.22:9002/team?user=lee&pwd=lee@123&func_local=switch&flag=0/1 -- 0 关闭 1 开启
- ]]
- local function team(args, ipaddr, header)
- logger.warn("处理来自主机team %s %s", ipaddr,args.func_local)
- -- 鉴权
- local user = args.user or ""
- local pwd = args.pwd or ""
- if authz[user] ~= pwd then
- return cjson.encode({errno = 403, host = header.host, info = "账号或密码错误"})
- end
- local func = args.func_local or ""
- logger.trace(" args = %s", stringify(args))
- if func == "player" and args.uids then
- local uids = cjson.decode(args.uids)
- local ok, ret = pcall(skynet.call,span_team, "lua", "web_load_player", uids)
- if not ok then
- logger.trace(" == 异常报错 %s", ret)
- return cjson.encode({errno = 400, host = header.host, info = "功能执行异常"})
- end
- elseif func == "team" and args.teamids then
- local teamids = cjson.decode(args.teamids)
- local ok, ret = pcall(skynet.call,span_team, "lua", "web_load_team", teamids)
- if not ok then
- logger.trace(" == 异常报错 %s", ret)
- return cjson.encode({errno = 400, host = header.host, info = "功能执行异常"})
- end
- elseif func == "switch" and args.flag then
- local ok, ret = pcall(skynet.call,span_team, "lua", "web_switch", args.flag)
- if not ok then
- logger.trace(" == 异常报错 %s", ret)
- return cjson.encode({errno = 400, host = header.host, info = "功能执行异常"})
- end
- if ret ~= 0 then
- return cjson.encode({errno = 400, host = header.host, info = "flag 参数异常"})
- end
- else
- return cjson.encode({errno = 400, host = header.host, info = "选择的功能不存在 或参数异常"})
- end
- return cjson.encode({errno = 200, host = header.host, info = "热更新 成功"})
- end
- return team
|