Class: OpenHAB::DSL::Imports::EventHandler
- Inherits:
-
Object
- Object
- OpenHAB::DSL::Imports::EventHandler
- Defined in:
- lib/rspec/openhab/dsl/imports.rb
Overview
reimplement to not use a thread
Instance Method Summary collapse
- #handle_event(osgi_event) ⇒ Object
-
#initialize(typed_event_subscribers, typed_event_factories) ⇒ EventHandler
constructor
A new instance of EventHandler.
Constructor Details
#initialize(typed_event_subscribers, typed_event_factories) ⇒ EventHandler
147 148 149 150 |
# File 'lib/rspec/openhab/dsl/imports.rb', line 147 def initialize(typed_event_subscribers, typed_event_factories) @typed_event_subscribers = typed_event_subscribers @typed_event_factories = typed_event_factories end |
Instance Method Details
#handle_event(osgi_event) ⇒ Object
152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/rspec/openhab/dsl/imports.rb', line 152 def handle_event(osgi_event) type = osgi_event.get_property("type") payload = osgi_event.get_property("payload") topic = osgi_event.get_property("topic") source = osgi_event.get_property("source") if type.is_a?(String) && payload.is_a?(String) && topic.is_a?(String) handle_event_internal(type, payload, topic, source) unless type.empty? || payload.empty? || topic.empty? else logger.error("The handled OSGi event is invalid. " \ "Expect properties as string named 'type', 'payload', and 'topic'. " \ "Received event properties are: #{properties.keys.inspect}") end end |