161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
|
# File 'lib/easy_upnp/control_point/device_control_point.rb', line 161
def on_event(callback, &block)
raise ArgumentError, 'Must provide block' if callback.nil?
options = EventConfigOptions.new(&block)
listener = EasyUpnp::HttpListener.new do |c|
options.configure_http_listener.call(c)
user_callback = c.callback
c.callback do |r|
user_callback.call(r) if user_callback
callback.call(r)
end
end
url = ->() { listener.listen }
manager = EasyUpnp::SubscriptionManager.new(@events_client, url) do |c|
options.configure_subscription_manager.call(c)
user_shutdown = c.on_shutdown
c.on_shutdown = ->() do
user_shutdown.call if user_shutdown
listener.shutdown
end
end
manager.subscribe
manager
end
|