Class: Hue::SSDP
- Inherits:
-
Object
- Object
- Hue::SSDP
- Defined in:
- lib/alexa_hue/hue_switch.rb
Constant Summary collapse
- MULTICAST_ADDR =
SSDP multicast IPv4 address
'239.255.255.250'.freeze
- MULTICAST_PORT =
SSDP UDP port
1900.freeze
- DEFAULT_SERVICE_TYPE =
Listen for all devices
'ssdp:all'.freeze
- DEFAULT_TIMEOUT =
Timeout in 2 seconds
2.freeze
Instance Attribute Summary collapse
-
#first ⇒ Object
readonly
Returns the value of attribute first.
-
#service_type ⇒ Object
readonly
Returns the value of attribute service_type.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
Instance Method Summary collapse
-
#devices ⇒ Object
Look for devices on the network.
-
#initialize(options = {}) ⇒ SSDP
constructor
A new instance of SSDP.
Constructor Details
#initialize(options = {}) ⇒ SSDP
Returns a new instance of SSDP.
467 468 469 470 471 472 |
# File 'lib/alexa_hue/hue_switch.rb', line 467 def initialize( = {}) @service_type = [:service_type] @timeout = ([:timeout] || DEFAULT_TIMEOUT) @first = [:first] initialize_socket end |
Instance Attribute Details
#first ⇒ Object (readonly)
Returns the value of attribute first.
463 464 465 |
# File 'lib/alexa_hue/hue_switch.rb', line 463 def first @first end |
#service_type ⇒ Object (readonly)
Returns the value of attribute service_type.
461 462 463 |
# File 'lib/alexa_hue/hue_switch.rb', line 461 def service_type @service_type end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
462 463 464 |
# File 'lib/alexa_hue/hue_switch.rb', line 462 def timeout @timeout end |
Instance Method Details
#devices ⇒ Object
Look for devices on the network
475 476 477 478 |
# File 'lib/alexa_hue/hue_switch.rb', line 475 def devices @socket.send(, 0, MULTICAST_ADDR, MULTICAST_PORT) listen_for_responses(first) end |