Skip to content

Commit

Permalink
Added @Expiration for device
Browse files Browse the repository at this point in the history
  • Loading branch information
turboladen committed Oct 3, 2012
1 parent 2dbceb1 commit 00c3fee
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 214 deletions.
13 changes: 13 additions & 0 deletions lib/upnp/control_point/device.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ class Device < Base
# @return [Hash] The whole parsed description... just in case.
attr_reader :description

attr_reader :expiration

#vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
# Determined by device description file.
#
Expand Down Expand Up @@ -139,6 +141,11 @@ def fetch
@ext = ssdp_notification.has_key?(:ext) ? true : false
@usn = ssdp_notification[:usn]
@date = ssdp_notification[:date] || ''
@expiration = if @date.empty?
Time.now + @cache_control
else
@date + @cache_control
end

if @location
get_description(@location, description_getter)
Expand Down Expand Up @@ -204,6 +211,12 @@ def extract_url_base
end
end

# True if the device hasn't received an alive notification since it last
# told its max age.
def expired?
Time.now > @expiration if @expiration
end

def has_devices?
!@device_list.empty?
end
Expand Down
17 changes: 0 additions & 17 deletions lib/upnp/ssdp/legacy/advertisement.rb

This file was deleted.

93 changes: 0 additions & 93 deletions lib/upnp/ssdp/legacy/notification.rb

This file was deleted.

66 changes: 0 additions & 66 deletions lib/upnp/ssdp/legacy/response.rb

This file was deleted.

38 changes: 0 additions & 38 deletions lib/upnp/ssdp/legacy/search.rb

This file was deleted.

0 comments on commit 00c3fee

Please sign in to comment.