class UPnPServerServlet
Public Instance Methods
do_GET(req, res)
click to toggle source
# File lib/upnp_server.rb, line 10 def do_GET(req, res) server = @options[0] if req.path.end_with? "device.xml" device_description = server.get_device_description req.path res.status = 200 res['Content-Type'] = 'text/xml; charset="utf-8"' res.body = device_description elsif req.path.end_with? "scpd.xml" scpd = server.get_scpd req.path res.status = 200 res['Content-Type'] = 'text/xml; charset="utf-8"' res.body = scpd end end
do_POST(req, res)
click to toggle source
# File lib/upnp_server.rb, line 25 def do_POST(req, res) server = @options[0] soap_req = UPnPSoapRequest.read req.body soap_res = server.on_action_request req.path soap_req res.status = 200 res['Content-Type'] = 'text/xml; charset="utf-8"' res.body = soap_res.to_s end
do_SUBSCRIBE(req, res)
click to toggle source
# File lib/upnp_server.rb, line 34 def do_SUBSCRIBE(req, res) server = @options[0] path = req.path if req['SID'] server.on_renew_subscription req['SID'] res.status = 200 else callback_urls = req['CALLBACK'].split(' ').map { |elem| elem[2..-1] } timeout = Integer(req['TIMEOUT'].split('-')[-1]) server.on_subscribe req.path timeout, callback_urls res.status = 200 end end
do_UNSUBSCRIBE(req, res)
click to toggle source
# File lib/upnp_server.rb, line 48 def do_UNSUBSCRIBE(req, res) server = @options[0] server.on_unsubscribe req['SID'] res.status = 200 end