mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-25 12:43:09 +00:00
fix login example
This commit is contained in:
@@ -17,7 +17,8 @@ function server.login_handler(uid, secret)
|
|||||||
end
|
end
|
||||||
|
|
||||||
internal_id = internal_id + 1
|
internal_id = internal_id + 1
|
||||||
local username = msgserver.username(uid, internal_id, servername)
|
local id = internal_id -- don't use internal_id directly
|
||||||
|
local username = msgserver.username(uid, id, servername)
|
||||||
|
|
||||||
-- you can use a pool to alloc new agent
|
-- you can use a pool to alloc new agent
|
||||||
local agent = skynet.newservice "msgagent"
|
local agent = skynet.newservice "msgagent"
|
||||||
@@ -25,11 +26,11 @@ function server.login_handler(uid, secret)
|
|||||||
username = username,
|
username = username,
|
||||||
agent = agent,
|
agent = agent,
|
||||||
uid = uid,
|
uid = uid,
|
||||||
subid = internal_id,
|
subid = id,
|
||||||
}
|
}
|
||||||
|
|
||||||
-- trash subid (no used)
|
-- trash subid (no used)
|
||||||
skynet.call(agent, "lua", "login", uid, internal_id, secret)
|
skynet.call(agent, "lua", "login", uid, id, secret)
|
||||||
|
|
||||||
users[uid] = u
|
users[uid] = u
|
||||||
username_map[username] = u
|
username_map[username] = u
|
||||||
@@ -37,7 +38,7 @@ function server.login_handler(uid, secret)
|
|||||||
msgserver.login(username, secret)
|
msgserver.login(username, secret)
|
||||||
|
|
||||||
-- you should return unique subid
|
-- you should return unique subid
|
||||||
return internal_id
|
return id
|
||||||
end
|
end
|
||||||
|
|
||||||
-- call by agent
|
-- call by agent
|
||||||
|
|||||||
Reference in New Issue
Block a user