Class: RUPNP::CP::EventServer
- Inherits:
-
EM::HttpServer::Server
- Object
- EM::HttpServer::Server
- RUPNP::CP::EventServer
- Includes:
- LogMixin
- Defined in:
- lib/rupnp/cp/event_server.rb
Overview
Event server to receive events from services.
Constant Summary
Constants included from LogMixin
Instance Attribute Summary collapse
-
#add_url ⇒ EM::Channel
readonly
Channel to add url for listening to.
Instance Method Summary collapse
-
#initialize(add_url_channel) ⇒ EventServer
constructor
A new instance of EventServer.
-
#process_http_request ⇒ Object
Process a HTTP request received from a service/device.
Methods included from LogMixin
Constructor Details
#initialize(add_url_channel) ⇒ EventServer
Returns a new instance of EventServer.
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rupnp/cp/event_server.rb', line 16 def initialize(add_url_channel) super @urls = [] @add_url = add_url_channel @add_url.subscribe do |url| log :info, "add URL #{url} for eventing" @urls << url end end |
Instance Attribute Details
#add_url ⇒ EM::Channel (readonly)
Channel to add url for listening to
12 13 14 |
# File 'lib/rupnp/cp/event_server.rb', line 12 def add_url @add_url end |
Instance Method Details
#process_http_request ⇒ Object
Process a HTTP request received from a service/device
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rupnp/cp/event_server.rb', line 29 def process_http_request log :debug, 'EventServer: receive request' url, event = @urls.find { |a| a[0] == @http_request_uri } if event.is_a? EM::Channel if @http_request_method == 'NOTIFY' if @http[:nt] == 'upnp:event' and @http[:nts] == 'upnp:propchange' event << { :sid => @http[:sid], :seq => @http[:seq], :content => @http_content } else log :warn, 'EventServer: ' + "malformed NOTIFY event message:\n#@http_headers\n#@http_content" end else log :warn, "EventServer: unknown HTTP verb: #@http_request_method" end end end |