mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-22 02:53:09 +00:00
@@ -1,17 +1,30 @@
|
||||
local skynet = require "skynet"
|
||||
local c = require "skynet.core"
|
||||
|
||||
local function number_address(name)
|
||||
local t = type(name)
|
||||
if t == "number" then
|
||||
return name
|
||||
elseif t == "string" then
|
||||
local hex = name:match "^:(%x+)"
|
||||
if hex then
|
||||
return tonumber(hex, 16)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function skynet.launch(...)
|
||||
local addr = c.command("LAUNCH", table.concat({...}," "))
|
||||
if addr then
|
||||
return tonumber("0x" .. string.sub(addr , 2))
|
||||
return tonumber(string.sub(addr , 2), 16)
|
||||
end
|
||||
end
|
||||
|
||||
function skynet.kill(name)
|
||||
if type(name) == "number" then
|
||||
skynet.send(".launcher","lua","REMOVE",name, true)
|
||||
name = skynet.address(name)
|
||||
local addr = number_address(name)
|
||||
if addr then
|
||||
skynet.send(".launcher","lua","REMOVE", addr, true)
|
||||
name = skynet.address(addr)
|
||||
end
|
||||
c.command("KILL",name)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user