Signed-off-by: Rahix <rahix@rahix.de>
dev
rahix 7 years ago
parent 2b935b87e4
commit 11babfad9e

@ -83,7 +83,7 @@ function Network:pull(filter, timeout)
if ev ~= nil then if ev ~= nil then
return last_msg return last_msg
else else
return nil, "timeout" return nil
end end
end end
@ -118,7 +118,6 @@ function BaseControl:new(network)
self.network:start(function(remote, msg) self.network:start(function(remote, msg)
self:_network_handler(remote, msg) self:_network_handler(remote, msg)
end) end)
-- Announce own presence so registers start coming in
self.network:broadcast{ty=Message.Hello} self.network:broadcast{ty=Message.Hello}
return self return self
@ -150,9 +149,7 @@ function BaseControl:register(name, value)
end end
function BaseControl:finalize(waits, timeout) function BaseControl:finalize(waits, timeout)
local self = self
if self == BaseControl then if self == BaseControl then
-- Called as a constructor
self = BaseControl:new() self = BaseControl:new()
end end
@ -167,6 +164,7 @@ function BaseControl:finalize(waits, timeout)
verbs=verbs, verbs=verbs,
} }
end end
self.live = true
end end
if #(waits or {}) ~= 0 then if #(waits or {}) ~= 0 then
@ -210,7 +208,6 @@ function BaseControl:finalize(waits, timeout)
end end
end end
self.live = true
return self return self
end end
@ -228,7 +225,6 @@ function BaseControl:close()
end end
self.network:stop() self.network:stop()
setmetatable(self, nil) setmetatable(self, nil)
end end
-- }}} -- }}}
@ -286,12 +282,12 @@ function BaseControl:set(name, value)
self.local_nouns[name] = value self.local_nouns[name] = value
for id, l in pairs(self.listeners[name] or {}) do for id, l in pairs(self.listeners[name] or {}) do
if (l.query.ty == Query.Change.ty and value ~= old) if (l.query.ty == Query.Change.ty and value ~= old)
or (l.query.ty == Query.Rising.ty and value > old) or (l.query.ty == Query.Rising.ty and value > old)
or (l.query.ty == Query.Falling.ty and value < old) or (l.query.ty == Query.Falling.ty and value < old)
or (l.query.ty == Query.Equals.ty and value == l.query.v) or (l.query.ty == Query.Equals.ty and value == l.query.v)
or (l.query.ty == Query.Above.ty and value > l.query.v) or (l.query.ty == Query.Above.ty and value > l.query.v)
or (l.query.ty == Query.Below.ty and value < l.query.v) or (l.query.ty == Query.Below.ty and value < l.query.v)
then then
if l.callback ~= nil then if l.callback ~= nil then
l.callback(value) l.callback(value)
@ -505,8 +501,6 @@ function BaseControl:_network_handler(remote, msg)
self.listeners[msg.noun][msg.id] = nil self.listeners[msg.noun][msg.id] = nil
end end
end end
else
error("TODO: MessageType Unknown")
end end
end end
-- }}} -- }}}

Loading…
Cancel
Save