LOGIN_D = {}
setmetatable(LOGIN_D, {__index = _G})
local _ENV = LOGIN_D
local private_key = "wugdGame"
local function connect_callback(agent, arg)
if not is_object(agent) then
trace("连接服务器失败.\n")
return
end
ME_D.set_agent(agent)
trace("----------------------success connected server-----------------------")
agent:send_message(CMD_INTERNAL_AUTH, 2, tostring(math.random(100000, 999999)), "")
local account = arg["account"]
local password = arg["password"]
local server_id = arg["server_id"] or 1
local login_info = {}
login_info["account"] = account
login_info["device_id"] = arg["device_id"]
login_info["password"] = calc_str_md5(password)
login_info["server_id"] = server_id
login_info["timestamp"] = os.time()
login_info["version"] = 1
for key, value in pairs(arg) do
agent.data[key] = value;
end
agent:send_message(CMD_LOGIN, login_info)
end
function login(account, password, extra_data)
if not START_STREE_TEST and ME_D.get_agent() then
return
end
local ip, port = GATE_IP, tonumber(GATE_CLIENT_PORT)
local ret = socket_connect(ip, port, 10000, connect_callback, {
account = account,
password = password,
extra_data = extra_data,
device_id = tostring(math.random(100000, 999999)),
server_id = 1,
})
if ret ~= 1 then
trace("连接服务器(%o:%o)失败。\n", ip, port)
return false
end
return true
end
function create()
end
create()