Module: Roku::Discover
- Defined in:
- lib/roku/discover.rb
Constant Summary collapse
- MULTICAST_ADDR =
'239.255.255.250'.freeze
- BIND_ADDR =
'0.0.0.0'.freeze
- PORT =
1900- REQUEST =
"M-SEARCH * HTTP/1.1\n" \ "Host: 239.255.255.250:1900\n" \ "Man: \"ssdp:discover\"\n" \ "ST: roku:ecp\n\n".freeze
Class Method Summary collapse
Class Method Details
.await_response ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/roku/discover.rb', line 20 def await_response Timeout.timeout(5) do loop do response, = socket.recvfrom(1024) if response.include?('LOCATION') && response.include?('200 OK') return response end end end end |
.search ⇒ Object
14 15 16 17 18 |
# File 'lib/roku/discover.rb', line 14 def search bind socket.send(REQUEST, 0, MULTICAST_ADDR, PORT) parse_address(await_response) end |