From b9e06dc0656e7be9e039201bc2b9efa175e53ac4 Mon Sep 17 00:00:00 2001 From: Cloud Wu Date: Fri, 14 Nov 2014 15:11:05 +0800 Subject: [PATCH] add snax.self and snax.exit --- lualib/snax.lua | 8 ++++++++ test/pingserver.lua | 5 +++++ test/testping.lua | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lualib/snax.lua b/lualib/snax.lua index f810e392..6a01460f 100644 --- a/lualib/snax.lua +++ b/lualib/snax.lua @@ -132,6 +132,14 @@ function snax.kill(obj, ...) skynet_call(obj.handle, "snax", t.system.exit, ...) end +function snax.self() + return snax.bind(skynet.self(), SERVICE_NAME) +end + +function snax.exit(...) + snax.kill(snax.self(), ...) +end + local function test_result(ok, ...) if ok then return ... diff --git a/test/pingserver.lua b/test/pingserver.lua index 2ddefd7f..5c44a21a 100644 --- a/test/pingserver.lua +++ b/test/pingserver.lua @@ -1,5 +1,6 @@ local skynet = require "skynet" local queue = require "skynet.queue" +local snax = require "snax" local i = 0 local hello = "hello" @@ -32,6 +33,10 @@ function accept.hello() end) end +function accept.exit(...) + snax.exit(...) +end + function response.error() error "throw an error" end diff --git a/test/testping.lua b/test/testping.lua index c9f05e63..fb0514e8 100644 --- a/test/testping.lua +++ b/test/testping.lua @@ -31,6 +31,6 @@ end print(string.format("%s\tcount:%d time:%f", name, v.count, v.time)) end - print(snax.kill(ps,"exit")) + print(ps.post.exit("exit")) -- == snax.kill(ps, "exit") skynet.exit() end)