ssdp 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45a022bdf308b1a26cb8e290067a9882f97e0d15
4
- data.tar.gz: c5b651cee29b9a61788da711ec6e9797fef72c2d
3
+ metadata.gz: f03eee0dcccb30c07cbfd0c3de98dc9c64cb62a3
4
+ data.tar.gz: d09d282461776840021fa715b597d6d584baf08f
5
5
  SHA512:
6
- metadata.gz: 60672a24ffd30f738f26773195cd2956be4c860a5580f5d79d4bea223e83d45587f4d38e5f114490f01e378da9fa1586eedb5ea575b090c9a69ad56d485d2257
7
- data.tar.gz: fd617fa6bc5d97013297fb7542cd58ebd5e6e9d2178d0f3534d3117f7ba5d12b45ab0a302c10207d893bad4f551cd80936b8bca25ade21c35e887069662660a1
6
+ metadata.gz: 9e918f1d49fa782311a04e99208e83b6708184294d923205f5d944519e7e23a689fcabc6ac7486fa7a423379cffa795c593dd3af0ab06e17bdf70b206483b86a
7
+ data.tar.gz: 33b923a275f71806812722350e1d5f25a05a2694fb33e47a26d947c6cd2d93736969f1a00bd65b69b8e406bb5fb33d0427aef2c39d5e8e74b9c05e9d48fb7c66
@@ -61,5 +61,4 @@ module SSDP
61
61
  broadcaster
62
62
  end
63
63
  module_function :create_broadcaster
64
-
65
64
  end
@@ -3,7 +3,7 @@ require 'ssdp'
3
3
 
4
4
  module SSDP
5
5
  class Consumer
6
- def initialize(options = {})
6
+ def initialize(options={})
7
7
  @options = SSDP::DEFAULTS.merge options
8
8
  @search_socket = SSDP.create_broadcaster
9
9
  @watch = {
@@ -13,13 +13,13 @@ module SSDP
13
13
  }
14
14
  end
15
15
 
16
- def search(options = {}, &block)
16
+ def search(options={}, &block)
17
17
  options = @options.merge options
18
18
  options[:callback] ||= block unless block.nil?
19
- fail "SSDP consumer async search missing callback." if (options[:synchronous] == false) && options[:callback].nil?
20
- fail "SSDP consumer search accepting multiple responses must specify a timeout value." if (options[:first_only] == false) && (options[:timeout].to_i < 1)
21
- warn "Warning: Calling SSDP search without a service specified." if options[:service].nil? && (options[:no_warnings] != true)
22
- warn "Warning: Calling SSDP search without a timeout value." if (options[:timeout].to_i < 1) && (options[:no_warnings] != true)
19
+ fail 'SSDP consumer async search missing callback.' if (options[:synchronous] == false) && options[:callback].nil?
20
+ fail 'SSDP consumer search accepting multiple responses must specify a timeout value.' if (options[:first_only] == false) && (options[:timeout].to_i < 1)
21
+ warn 'Warning: Calling SSDP search without a service specified.' if options[:service].nil? && (options[:no_warnings] != true)
22
+ warn 'Warning: Calling SSDP search without a timeout value.' if (options[:timeout].to_i < 1) && (options[:no_warnings] != true)
23
23
 
24
24
  @search_socket.send compose_search(options), 0, options[:broadcast], options[:port]
25
25
 
@@ -37,12 +37,12 @@ module SSDP
37
37
 
38
38
  def stop_watching_type(type)
39
39
  @watch[:services].delete type
40
- stop_watch if (@watch[:services].count == 0) && (@watch[:thread] != nil)
40
+ stop_watch if (@watch[:services].count == 0) && @watch[:thread]
41
41
  end
42
42
 
43
43
  def stop_watching_all
44
44
  @watch[:services] = {}
45
- stop_watch if @watch[:thread] != nil
45
+ stop_watch if @watch[:thread]
46
46
  end
47
47
 
48
48
  private
@@ -52,7 +52,7 @@ module SSDP
52
52
  "Host: #{options[:broadcast]}:#{options[:port]}\n" \
53
53
  "Man: \"ssdp:discover\"\n"
54
54
  query += "ST: #{options[:service]}\n" if options[:service]
55
- options[:params].each { |key, val| query += "#{key}: #{value}\n" } if options[:params]
55
+ options[:params].each { |key, val| query += "#{key}: #{val}\n" } if options[:params]
56
56
  query + "\n"
57
57
  end
58
58
 
@@ -80,7 +80,7 @@ module SSDP
80
80
  began = Time.now
81
81
  remaining = options[:timeout]
82
82
  while !found && remaining > 0
83
- ready = IO::select [@search_socket], nil, nil, remaining
83
+ ready = IO.select [@search_socket], nil, nil, remaining
84
84
  if ready
85
85
  message, producer = @search_socket.recvfrom options[:maxpack]
86
86
  result = process_ssdp_packet message, producer
@@ -89,7 +89,7 @@ module SSDP
89
89
  remaining = options[:timeout] - (Time.now - began).to_i
90
90
  end
91
91
  else
92
- while !found
92
+ until found
93
93
  message, producer = @search_socket.recvfrom options[:maxpack]
94
94
  result = process_ssdp_packet message, producer
95
95
  found = options[:filter].nil? ? true : options[:filter].call(result)
@@ -109,7 +109,7 @@ module SSDP
109
109
 
110
110
  while remaining > 0
111
111
  start_time = Time.now
112
- ready = IO::select [@search_socket], nil, nil, remaining
112
+ ready = IO.select [@search_socket], nil, nil, remaining
113
113
  if ready
114
114
  message, producer = @search_socket.recvfrom options[:maxpack]
115
115
  if options[:filter].nil?
@@ -138,7 +138,7 @@ module SSDP
138
138
  @watch[:socket] = SSDP.create_listener @options
139
139
  @watch[:thread] = Thread.new do
140
140
  begin
141
- while true
141
+ loop do
142
142
  message, producer = @watch[:socket].recvfrom @options[:maxpack]
143
143
  notification = process_ssdp_packet message, producer
144
144
  notification_type = notification[:params]['NT']
@@ -154,6 +154,5 @@ module SSDP
154
154
  @watch[:thread].exit
155
155
  @watch[:thread] = nil
156
156
  end
157
-
158
157
  end
159
158
  end
@@ -7,7 +7,7 @@ module SSDP
7
7
  attr_accessor :services
8
8
  attr_accessor :uuid
9
9
 
10
- def initialize(options = {})
10
+ def initialize(options={})
11
11
  @uuid = SecureRandom.uuid
12
12
  @services = {}
13
13
  @listener = { :socket => nil, :thread => nil }
@@ -24,14 +24,14 @@ module SSDP
24
24
  start_listener if @listener[:thread].nil?
25
25
  end
26
26
 
27
- def stop(bye_bye = true)
27
+ def stop(bye_bye=true)
28
28
  was_running = running?
29
29
 
30
- if @listener[:thread] != nil
30
+ if @listener[:thread]
31
31
  @listener[:thread].exit
32
32
  @listener[:thread] = nil
33
33
  end
34
- if @notifier[:thread] != nil
34
+ if @notifier[:thread]
35
35
  @notifier[:thread].exit
36
36
  @notifier[:thread] = nil
37
37
  end
@@ -123,7 +123,7 @@ module SSDP
123
123
  @listener[:socket] = SSDP.create_listener @options
124
124
  @listener[:thread] = Thread.new do
125
125
  begin
126
- while true
126
+ loop do
127
127
  message, consumer = @listener[:socket].recvfrom @options[:maxpack]
128
128
  process_ssdp message, { :address => consumer[3], :port => consumer[1] } unless @services.count == 0
129
129
  end
@@ -135,12 +135,11 @@ module SSDP
135
135
 
136
136
  def start_notifier
137
137
  @notifier[:thread] = Thread.new do
138
- while true
138
+ loop do
139
139
  sleep @options[:interval]
140
140
  @services.each { |type, params| send_notification type, params }
141
141
  end
142
142
  end
143
143
  end
144
-
145
144
  end
146
145
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ssdp
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dillon Aumiller
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-03 00:00:00.000000000 Z
11
+ date: 2015-02-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: SSDP client/server library. Server notify/part/respond; client search/listen.
14
14
  email: dillonaumiller@gmail.com