mirror of
https://github.com/cloudwu/skynet.git
synced 2026-07-24 20:23:06 +00:00
@@ -1,17 +1,30 @@
|
|||||||
local skynet = require "skynet"
|
local skynet = require "skynet"
|
||||||
local c = require "skynet.core"
|
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(...)
|
function skynet.launch(...)
|
||||||
local addr = c.command("LAUNCH", table.concat({...}," "))
|
local addr = c.command("LAUNCH", table.concat({...}," "))
|
||||||
if addr then
|
if addr then
|
||||||
return tonumber("0x" .. string.sub(addr , 2))
|
return tonumber(string.sub(addr , 2), 16)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function skynet.kill(name)
|
function skynet.kill(name)
|
||||||
if type(name) == "number" then
|
local addr = number_address(name)
|
||||||
skynet.send(".launcher","lua","REMOVE",name, true)
|
if addr then
|
||||||
name = skynet.address(name)
|
skynet.send(".launcher","lua","REMOVE", addr, true)
|
||||||
|
name = skynet.address(addr)
|
||||||
end
|
end
|
||||||
c.command("KILL",name)
|
c.command("KILL",name)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user