Class: Frisky::SSDP::Notifier
- Inherits:
-
MulticastConnection
- Object
- EventMachine::Connection
- MulticastConnection
- Frisky::SSDP::Notifier
- Includes:
- LogSwitch
- Defined in:
- lib/frisky/ssdp/notifier.rb
Constant Summary
Constants included from NetworkConstants
Frisky::SSDP::NetworkConstants::BROADCAST_IP, Frisky::SSDP::NetworkConstants::MULTICAST_IP, Frisky::SSDP::NetworkConstants::MULTICAST_PORT, Frisky::SSDP::NetworkConstants::TTL
Instance Method Summary collapse
-
#initialize(nt, usn, ddf_url, valid_for_duration) ⇒ Notifier
constructor
A new instance of Notifier.
- #notification(nt, usn, ddf_url, valid_for_duration) ⇒ Object
- #post_init ⇒ Object
Methods inherited from MulticastConnection
#parse, #peer_info, #set_membership, #set_multicast_ttl, #set_ttl, #setup_multicast_socket, #switch_multicast_loop
Constructor Details
#initialize(nt, usn, ddf_url, valid_for_duration) ⇒ Notifier
Returns a new instance of Notifier.
8 9 10 11 12 13 |
# File 'lib/frisky/ssdp/notifier.rb', line 8 def initialize(nt, usn, ddf_url, valid_for_duration) @os = RbConfig::CONFIG['host_vendor'].capitalize + '/' + RbConfig::CONFIG['host_os'] @upnp_version = '1.0' @notification = notification(nt, usn, ddf_url, valid_for_duration) end |
Instance Method Details
#notification(nt, usn, ddf_url, valid_for_duration) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/frisky/ssdp/notifier.rb', line 28 def notification(nt, usn, ddf_url, valid_for_duration) <<-NOTIFICATION NOTIFY * HTTP/1.1\r HOST: #{MULTICAST_IP}:#{MULTICAST_PORT}\r CACHE-CONTROL: max-age=#{valid_for_duration}\r LOCATION: #{ddf_url}\r NT: #{nt}\r NTS: ssdp:alive\r SERVER: #{@os} UPnP/#{@upnp_version} Frisky/#{Frisky::VERSION}\r USN: #{usn}\r \r NOTIFICATION end |
#post_init ⇒ Object
15 16 17 18 19 |
# File 'lib/frisky/ssdp/notifier.rb', line 15 def post_init if send_datagram(@notification, MULTICAST_IP, MULTICAST_PORT) > 0 log "Sent notification:\n#{@notification}" end end |