diff --git a/HISTORY.md b/HISTORY.md index f3da837ba..5098f75cc 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,7 @@ +v0.6.2 (2014-9-1) +----------- +* bugfix: only skynet.call response PTYPE_ERROR + v0.6.1 (2014-8-25) ----------- * bugfix: datacenter.wakeup diff --git a/test/testresponse.lua b/test/testresponse.lua new file mode 100644 index 000000000..aabbbabac --- /dev/null +++ b/test/testresponse.lua @@ -0,0 +1,44 @@ +local skynet = require "skynet" + +local mode = ... + +if mode == "TICK" then +-- this service whould response the request every 1s. + +local response_queue = {} + +local function response() + while true do + skynet.sleep(100) -- sleep 1s + for k,v in ipairs(response_queue) do + v(true, skynet.now()) -- true means succ, false means error + response_queue[k] = nil + end + end +end + +skynet.start(function() + skynet.fork(response) + skynet.dispatch("lua", function() + table.insert(response_queue, skynet.response()) + end) +end) + +else + +local function request(tick, i) + print(i, "call", skynet.now()) + print(i, "response", skynet.call(tick, "lua")) + print(i, "end", skynet.now()) +end + +skynet.start(function() + local tick = skynet.newservice(SERVICE_NAME, "TICK") + + for i=1,5 do + skynet.fork(request, tick, i) + skynet.sleep(10) + end +end) + +end \ No newline at end of file