Class: EasyUpnp::EventClient
- Inherits:
-
Object
- Object
- EasyUpnp::EventClient
show all
- Defined in:
- lib/easy_upnp/events/event_client.rb
Defined Under Namespace
Classes: EventRequest, ResubscribeRequest, SubscribeRequest, SubscribeResponse, SubscriptionError, UnsubscribeRequest
Instance Method Summary
collapse
Constructor Details
#initialize(events_endpoint) ⇒ EventClient
Returns a new instance of EventClient.
7
8
9
|
# File 'lib/easy_upnp/events/event_client.rb', line 7
def initialize(events_endpoint)
@events_endpoint = URI(events_endpoint)
end
|
Instance Method Details
#resubscribe(sid, timeout: 300) ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
|
# File 'lib/easy_upnp/events/event_client.rb', line 36
def resubscribe(sid, timeout: 300)
req = ResubscribeRequest.new(
@events_endpoint,
sid,
timeout
)
response = do_request(req)
SubscribeResponse.new(response)
end
|
#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
|
#unsubscribe(sid) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'lib/easy_upnp/events/event_client.rb', line 27
def unsubscribe(sid)
req = UnsubscribeRequest.new(
@events_endpoint,
sid
)
do_request(req)
true
end
|