added disconnecter
This commit is contained in:
parent
8d80a824b3
commit
fb322a95e8
2 changed files with 40 additions and 1 deletions
|
|
@ -72,6 +72,39 @@ function module.init(shared)
|
|||
-- when created binding
|
||||
new.created = prefix .. "Created::";
|
||||
new.createdSync = prefix .. "CreatedSync::";
|
||||
|
||||
-- roblox connections disconnecter
|
||||
local insert = table.insert;
|
||||
local idSpace = {};
|
||||
local disconnecter = {};
|
||||
function disconnecter:add(connection)
|
||||
insert(self,connection);
|
||||
end
|
||||
function disconnecter:destroy()
|
||||
local id = self.id;
|
||||
if id then
|
||||
idSpace[id] = nil;
|
||||
end
|
||||
for i,v in pairs(self) do
|
||||
pcall(v.Disconnect,v);
|
||||
self[i] = nil;
|
||||
end
|
||||
end
|
||||
disconnecter.__index = disconnecter;
|
||||
function new.new(id)
|
||||
if id then
|
||||
local old = idSpace[id];
|
||||
if old then
|
||||
return old;
|
||||
end
|
||||
end
|
||||
local this = setmetatable({id = id},disconnecter);
|
||||
if id then
|
||||
idSpace[id] = this;
|
||||
end
|
||||
return this;
|
||||
end
|
||||
|
||||
return new;
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -141,11 +141,17 @@ function module.init(shared)
|
|||
self[key] = self[key] or value;
|
||||
end
|
||||
function new.new(self,id)
|
||||
if id then
|
||||
local old = storeIdSpace[id];
|
||||
if old then
|
||||
return old;
|
||||
end
|
||||
end
|
||||
local this = setmetatable(
|
||||
{__self = self or {},__evt = setmetatable({},week),__reg = setmetatable({},week)},store
|
||||
);
|
||||
if id then
|
||||
storeIdSpace[id] = id;
|
||||
storeIdSpace[id] = this;
|
||||
end
|
||||
return this;
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue