From 11babfad9ebddf83061c32d255ea7ea3a36a3b4f Mon Sep 17 00:00:00 2001 From: Rahix Date: Wed, 17 Apr 2019 22:22:13 +0200 Subject: [PATCH] Cleanup Signed-off-by: Rahix --- bc.lua | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/bc.lua b/bc.lua index efc344fc2ccd..11622a68c6a7 100644 --- a/bc.lua +++ b/bc.lua @@ -83,7 +83,7 @@ function Network:pull(filter, timeout) if ev ~= nil then return last_msg else - return nil, "timeout" + return nil end end @@ -118,7 +118,6 @@ function BaseControl:new(network) self.network:start(function(remote, msg) self:_network_handler(remote, msg) end) - -- Announce own presence so registers start coming in self.network:broadcast{ty=Message.Hello} return self @@ -150,9 +149,7 @@ function BaseControl:register(name, value) end function BaseControl:finalize(waits, timeout) - local self = self if self == BaseControl then - -- Called as a constructor self = BaseControl:new() end @@ -167,6 +164,7 @@ function BaseControl:finalize(waits, timeout) verbs=verbs, } end + self.live = true end if #(waits or {}) ~= 0 then @@ -210,7 +208,6 @@ function BaseControl:finalize(waits, timeout) end end - self.live = true return self end @@ -228,7 +225,6 @@ function BaseControl:close() end self.network:stop() - setmetatable(self, nil) end -- }}} @@ -286,12 +282,12 @@ function BaseControl:set(name, value) self.local_nouns[name] = value for id, l in pairs(self.listeners[name] or {}) do - if (l.query.ty == Query.Change.ty and value ~= old) - or (l.query.ty == Query.Rising.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.Falling.ty and value < old) - 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.Below.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.Below.ty and value < l.query.v) then if l.callback ~= nil then l.callback(value) @@ -505,8 +501,6 @@ function BaseControl:_network_handler(remote, msg) self.listeners[msg.noun][msg.id] = nil end end - else - error("TODO: MessageType Unknown") end end -- }}}