From 08c511160fd03465a25e78202b0e24e02dd49314 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Tue, 22 Apr 2014 11:40:08 +0800 Subject: [PATCH] change name from pub/subscribe to post/accept --- lualib/snax.lua | 8 ++++---- lualib/snax_interface.lua | 4 ++-- service/snaxd.lua | 4 ++-- test/pingserver.lua | 2 +- test/testping.lua | 6 +++--- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lualib/snax.lua b/lualib/snax.lua index e60aa293..67dafc7e 100644 --- a/lualib/snax.lua +++ b/lualib/snax.lua @@ -14,7 +14,7 @@ function snax.interface(name) local si = snax_interface(name, G) local ret = { - subscribe = {}, + accept = {}, response = {}, system = {}, } @@ -33,10 +33,10 @@ local meta = { __tostring = function(v) return string.format("[%s:%x]", v.type, local skynet_send = skynet.send local skynet_call = skynet.call -local function gen_pub(type, handle) +local function gen_post(type, handle) return setmetatable({} , { __index = function( t, k ) - local id = assert(type.subscribe[k] , string.format("publish %s no exist", k)) + local id = assert(type.accept[k] , string.format("post %s no exist", k)) return function(...) skynet_send(handle, "lua", id, ...) end @@ -55,7 +55,7 @@ end local function wrapper(handle, name, type) return setmetatable ({ - pub = gen_pub(type, handle), + post = gen_post(type, handle), req = gen_req(type, handle), type = name, handle = handle, diff --git a/lualib/snax_interface.lua b/lualib/snax_interface.lua index 03e6f5e5..24d52c08 100644 --- a/lualib/snax_interface.lua +++ b/lualib/snax_interface.lua @@ -27,7 +27,7 @@ return function (name , G, loader) assert(G.init == nil) assert(G.exit == nil) - assert(G.subscribe == nil) + assert(G.accept == nil) assert(G.response == nil) end @@ -44,7 +44,7 @@ return function (name , G, loader) end end - env.subscribe = func_id(func, "subscribe") + env.accept = func_id(func, "accept") env.response = func_id(func, "response") local function init_system(t, name, f) diff --git a/service/snaxd.lua b/service/snaxd.lua index 59fe756a..d19c8b42 100644 --- a/service/snaxd.lua +++ b/service/snaxd.lua @@ -26,7 +26,7 @@ local function message_dispatch() local method = msg.method local f = method[4] if f then - if method[2] == "subscribe" then + if method[2] == "accept" then -- no return local ok, data = pcall(f, table.unpack(msg)) if not ok then @@ -94,7 +94,7 @@ skynet.start(function() assert(init, "Init first") if mode == "queue" then queue(session, source, method , ...) - elseif method[2] == "subscribe" then + elseif method[2] == "accept" then -- no return method[4](...) else diff --git a/test/pingserver.lua b/test/pingserver.lua index f36166bb..635cfeab 100644 --- a/test/pingserver.lua +++ b/test/pingserver.lua @@ -8,7 +8,7 @@ function response.ping(hello) return hello end -function subscribe.hello() +function accept.hello() i = i + 1 print (i, hello) end diff --git a/test/testping.lua b/test/testping.lua index 1244551e..06746705 100644 --- a/test/testping.lua +++ b/test/testping.lua @@ -4,14 +4,14 @@ local snax = require "snax" skynet.start(function() local ps = snax.newservice ("pingserver", "hello world") print(ps.req.ping("foobar")) - print(ps.pub.hello()) + print(ps.post.hello()) print(pcall(ps.req.error)) print("Hotfix (i) :", snax.hotfix(ps, [[ local i local hello -function subscribe.hello() +function accept.hello() i = i + 1 print ("fix", i, hello) end @@ -23,7 +23,7 @@ function hotfix(...) end ]])) - print(ps.pub.hello()) + print(ps.post.hello()) print(snax.kill(ps,"exit")) skynet.exit() end)