Class: LIFX::Site Private
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Instance Attribute Summary collapse
- #gateways ⇒ Object readonly private
- #id ⇒ Object readonly private
- #tag_manager ⇒ Object readonly private
Instance Method Summary collapse
- #flush(**options) ⇒ Object private
- #handle_message(message, ip, transport) ⇒ Object private
-
#initialize(id:) ⇒ Site
constructor
private
A new instance of Site.
- #stop ⇒ Object private
- #to_s ⇒ Object (also: #inspect) private
- #write(message) ⇒ Object private
Methods included from Seen
#last_seen, #seconds_since_seen
Constructor Details
#initialize(id:) ⇒ Site
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Site.
16 17 18 19 20 21 22 23 |
# File 'lib/lifx/site.rb', line 16 def initialize(id:) @id = id @gateways = {} @gateways_mutex = Mutex.new @threads = [] @threads << initialize_timer_thread initialize_stale_gateway_check end |
Instance Attribute Details
#gateways ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/lifx/site.rb', line 14 def gateways @gateways end |
#id ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/lifx/site.rb', line 14 def id @id end |
#tag_manager ⇒ Object (readonly)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
14 15 16 |
# File 'lib/lifx/site.rb', line 14 def tag_manager @tag_manager end |
Instance Method Details
#flush(**options) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
48 49 50 51 52 53 54 |
# File 'lib/lifx/site.rb', line 48 def flush(**) @gateways.values.map do |gateway| Thread.new do gateway.flush(**) end end.each(&:join) end |
#handle_message(message, ip, transport) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/lifx/site.rb', line 32 def (, ip, transport) logger.debug("<- #{self} #{transport}: #{}") payload = .payload case payload when Protocol::Device::StatePanGateway @gateways_mutex.synchronize do @gateways[.device_id] ||= GatewayConnection.new @gateways[.device_id].(, ip, transport) @gateways[.device_id].add_observer(self) do |**args| notify_observers(**args) end end end seen! end |
#stop ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
61 62 63 64 65 66 67 68 |
# File 'lib/lifx/site.rb', line 61 def stop @threads.each do |thread| Thread.kill(thread) end @gateways.values.each do |gateway| gateway.close end end |
#to_s ⇒ Object Also known as: inspect
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
56 57 58 |
# File 'lib/lifx/site.rb', line 56 def to_s %Q{#<LIFX::Site id=#{id}>} end |
#write(message) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
25 26 27 28 29 30 |
# File 'lib/lifx/site.rb', line 25 def write() .path.site_id = id @gateways.values.each do |gateway| gateway.write() end end |