Method: EasyUpnp::EventClient#subscribe

Defined in:
lib/easy_upnp/events/event_client.rb

#subscribe(callback, timeout: 300) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/easy_upnp/events/event_client.rb', line 11

def subscribe(callback, timeout: 300)
  req = SubscribeRequest.new(
    @events_endpoint,
    callback,
    timeout
  )

  response = do_request(req)

  if !response['SID']
    raise SubscriptionError, "SID header not present in response: #{response.to_hash}"
  end

  SubscribeResponse.new(response)
end