Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Openhome incomplete eventing #9

Open
arjunmenon opened this issue Dec 11, 2017 · 14 comments
Open

Openhome incomplete eventing #9

arjunmenon opened this issue Dec 11, 2017 · 14 comments

Comments

@arjunmenon
Copy link

arjunmenon commented Dec 11, 2017

Hey
For openhome devices, the eventing does not show the XML. It simply shows the action changed but not the XML.

Id ==>
<?xml version="1.0"?>

The property text is also empty.

@sidoh
Copy link
Owner

sidoh commented Dec 11, 2017

Think that happens here:

https://github.com/sidoh/easy_upnp/blob/master/lib/easy_upnp/events/event_parser.rb#L7-L9

This is not currently optional, but wouldn't be hard to expose a setting if it'd be useful.

@arjunmenon
Copy link
Author

Not sure. The namespace returned is the same -

> null '{"e:propertyset":{"$":{"xmlns:e":"urn:schemas-upnp-org:event-1-0"},"e:property":{"Id":"5"}}}'

@sidoh
Copy link
Owner

sidoh commented Dec 12, 2017

Where is that from? Why is it JSON?

@arjunmenon
Copy link
Author

Sorry for that. I thought I linked it.
I was looking at a node output - https://github.com/bazwilliams/node-upnp-subscription

@arjunmenon
Copy link
Author

arjunmenon commented Dec 13, 2017

Here is a complete response from a simple server listening to any requests from the renderer.

Listening on localhost:8081

----- Request Start ----->

/
HOST: 192.168.1.11:8081
CONTENT-TYPE: text/xml; charset="utf-8"
CONTENT-LENGTH: 123
NT: upnp:event
NTS: upnp:propchange
SID: uuid:6525502a-e01d-11e7-87bb-97eb06848d94
SEQ: 3

<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0">
<e:property>
<Repeat>0</Repeat>
</e:property>
</e:propertyset>



<----- Request End -----

The renderer only supports openhome.

@sidoh
Copy link
Owner

sidoh commented Dec 13, 2017

And the issue you're meaning to raise is that easy_upnp returns just the Repeat: 0 part, right? It's intentional that it's parsed, but I could make it optional behavior, or at least return both the parsed and the raw result.

@arjunmenon
Copy link
Author

arjunmenon commented Dec 14, 2017

Hey
It justs returns this

Repeat ==>
<?xml version="1.0"?>

That is no mention of the params.
I think hardcoding would restrict to certain cases. Songcast has a different approach. I would suggest your idea to simply return the raw result. Let the user decide what to do. Not trivial to parse. Even the headers. Sid is required.

The library really is easy to work with. Takes care of everything. Access to raw result, in my opinion, should be an option.

@sidoh
Copy link
Owner

sidoh commented Dec 14, 2017

Makes sense. I'll try to add that when I get some spare time (should be in next couple of days). Also happy to look at a PR.

@sidoh
Copy link
Owner

sidoh commented Dec 30, 2017

@arjunmenon, I added an option to override the parser:

service.on_event(callback) do |c|
  c.configure_http_listener do |l|
    l.event_parser = EasyUpnp::NoOpEventParser
  end
end

Should be available in 1.2.0, which will be released when the Travis build finishes. Can you try it out and let me know if it works for you?

@arjunmenon
Copy link
Author

arjunmenon commented Dec 30, 2017

Hey
I am getting this error

irb(main):010:0> callback = ->(state_vars) do
irb(main):011:1*   state_vars.map do |var, value|
irb(main):012:2*     puts "#{var} ==>"
irb(main):013:2>     puts Nokogiri::XML(value).to_xml
irb(main):014:2>   end
irb(main):015:1> end
=> #<Proc:0x00555cad474f28@(irb):10 (lambda)>
irb(main):016:0> manager = service.on_event(callback) do |c|
irb(main):017:1*   c.configure_http_listener do |l|
irb(main):018:2*       l.event_parser = EasyUpnp::NoOpEventParser
irb(main):019:2>   end
irb(main):020:1> end
[2017-12-31 01:29:55] INFO  WEBrick 1.3.1
[2017-12-31 01:29:55] INFO  ruby 2.3.3 (2016-11-21) [x86_64-linux]
=> #<EasyUpnp::SubscriptionManager:0x00555cad447438 @options=#<EasyUpnp::Options:0x00555cad447398 @options={:requested_timeout=>300, :resubscription_interval_buffer=>10, :existing_sid=>nil, :logger=>#<Logger:0x00555cad647bc0 @progname=nil, @level=2, @default_formatter=#<Logger::Formatter:0x00555cad647b98 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0x00555cad647b48 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x00555cad647af8>>>, :log_level=>2, :on_shutdown=>#<Proc:0x00555cad446510@/home/arjun/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/easy_upnp-1.2.0/lib/easy_upnp/control_point/device_control_point.rb:187 (lambda)>}>, @event_client=#<EasyUpnp::EventClient:0x00555cad51bf58 @events_endpoint=#<URI::HTTP http://192.168.1.4:49152/evt/OHPlaylist>>, @callback_url=#<Proc:0x00555cad447488@/home/arjun/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/easy_upnp-1.2.0/lib/easy_upnp/control_point/device_control_point.rb:181 (lambda)>, @sid=nil, @subscription_thread=#<Thread:0x00555cad445ea8@/home/arjun/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/easy_upnp-1.2.0/lib/easy_upnp/events/subscription_manager.rb:54 sleep>>
irb(main):021:0> [2017-12-31 01:29:55] INFO  WEBrick::HTTPServer#start: pid=14057 port=37211
[2017-12-31 01:29:55] ERROR NoMethodError: undefined method `map' for #<String:0x00555cad4341f8>
Did you mean?  tap
	(irb):11:in `block in irb_binding'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/easy_upnp-1.2.0/lib/easy_upnp/control_point/device_control_point.rb:175:in `block (2 levels) in on_event'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/easy_upnp-1.2.0/lib/easy_upnp/events/http_listener.rb:80:in `do_NOTIFY'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/webrick/httpservlet/abstract.rb:107:in `service'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'
[2017-12-31 01:30:16] ERROR NoMethodError: undefined method `map' for #<String:0x00555cad410e10>
Did you mean?  tap
	(irb):11:in `block in irb_binding'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/easy_upnp-1.2.0/lib/easy_upnp/control_point/device_control_point.rb:175:in `block (2 levels) in on_event'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/easy_upnp-1.2.0/lib/easy_upnp/events/http_listener.rb:80:in `do_NOTIFY'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/webrick/httpservlet/abstract.rb:107:in `service'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:140:in `service'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/webrick/httpserver.rb:96:in `run'
	/home/arjun/.rbenv/versions/2.3.3/lib/ruby/2.3.0/webrick/server.rb:296:in `block in start_thread'
[2017-12-31 01:30:59] ERROR NoMethodError: undefined method `map' for #<String:0x00555cad3dac70>
Did you mean?  tap

The state_vars was later inspected to get output without errors. But why is it returning a string class?
I think it's because, earlier the DefaultEventParser class returned a Nokogiri object as a Hash. Need to do the same with the NoOpEventParser

irb(main):010:0> callback = ->(state_vars) do
irb(main):011:1*     puts state_vars.inspect
irb(main):012:1> end
irb(main):014:0> manager = service.on_event(callback)  do |c|
irb(main):015:1*     c.configure_http_listener do |l|
irb(main):016:2*        l.event_parser = EasyUpnp::NoOpEventParser
irb(main):017:2>   end
irb(main):018:1> end
[2017-12-31 01:42:42] INFO  WEBrick 1.3.1
[2017-12-31 01:42:42] INFO  ruby 2.3.3 (2016-11-21) [x86_64-linux]
=> #<EasyUpnp::SubscriptionManager:0x0055dd5e6f5860 @options=#<EasyUpnp::Options:0x0055dd5e6f57e8 @options={:requested_timeout=>300, :resubscription_interval_buffer=>10, :existing_sid=>nil, :logger=>#<Logger:0x0055dd5e9d2a60 @progname=nil, @level=2, @default_formatter=#<Logger::Formatter:0x0055dd5e9d2970 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0x0055dd5e9d2880 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x0055dd5e9d2790>>>, :log_level=>2, :on_shutdown=>#<Proc:0x0055dd5e6f4960@/home/arjun/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/easy_upnp-1.2.0/lib/easy_upnp/control_point/device_control_point.rb:187 (lambda)>}>, @event_client=#<EasyUpnp::EventClient:0x0055dd5e916680 @events_endpoint=#<URI::HTTP http://192.168.1.4:49152/evt/OHPlaylist>>, @callback_url=#<Proc:0x0055dd5e6f5888@/home/arjun/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/easy_upnp-1.2.0/lib/easy_upnp/control_point/device_control_point.rb:181 (lambda)>, @sid=nil, @subscription_thread=#<Thread:0x0055dd5e6f4988@/home/arjun/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/easy_upnp-1.2.0/lib/easy_upnp/events/subscription_manager.rb:54 sleep>>
irb(main):019:0> [2017-12-31 01:42:42] INFO  WEBrick::HTTPServer#start: pid=14326 port=46211
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<IdArray>AAAAAQAAAAIAAAADAAAABAAAAAUAAAAGAAAABwAAAAgAAAAJAAAACgAAAAsAAAAMAAAADQAAAA4AAAAPAAAAEA==</IdArray>\n</e:property>\n<e:property>\n<TracksMax>16384</TracksMax>\n</e:property>\n<e:property>\n<ProtocolInfo>http-get:*:audio/L16:DLNA.ORG_PN=LPCM,http-get:*:application/flac:*,http-get:*:application/x-flac:*,http-get:*:audio/flac:*,http-get:*:audio/x-flac:*,http-get:*:audio/aac:*,http-get:*:audio/x-aiff:*,http-get:*:audio/aif:*,http-get:*:audio/aiff:*,http-get:*:audio/dff:*,http-get:*:audio/x-dff:*,http-get:*:audio/dsd:*,http-get:*:audio/x-dsd:*,http-get:*:audio/dsf:*,http-get:*:audio/x-dsf:*,http-get:*:audio/m4a:*,http-get:*:audio/x-m4a:*,http-get:*:audio/mp1:*,http-get:*:audio/mp4:*,http-get:*:audio/mpeg:*,http-get:*:audio/x-mpeg:*,http-get:*:audio/ogg:*,http-get:*:audio/vorbis:*,http-get:*:audio/x-ape:*,http-get:*:audio/x-monkeys-audio:*,http-get:*:audio/wav:*,http-get:*:audio/x-wav:*,http-get:*:audio/wave:*,http-get:*:audio/x-ms-wma:*,http-get:*:audio/x-ogg:*,http-get:*:audio/x-scpls:*,http-get:*:audio/x-vorbis+ogg:*,http-get:*:audio/x-vorbis:*,http-get:*:audio/x-wavpack:*,http-get:*:video/mp4:*</ProtocolInfo>\n</e:property>\n<e:property>\n<Id>7</Id>\n</e:property>\n<e:property>\n<Shuffle>0</Shuffle>\n</e:property>\n<e:property>\n<Repeat>1</Repeat>\n</e:property>\n<e:property>\n<TransportState>Playing</TransportState>\n</e:property>\n</e:propertyset>\n\n\r\n"
{:Repeat=>"0"}
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<Repeat>0</Repeat>\n</e:property>\n</e:propertyset>\n\n\r\n"
{:Repeat=>"1"}"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<Repeat>1</Repeat>\n</e:property>\n</e:propertyset>\n\n\r\n"

"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<Shuffle>1</Shuffle>\n</e:property>\n</e:propertyset>\n\n\r\n"
{:Shuffle=>"1"}
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<Shuffle>0</Shuffle>\n</e:property>\n</e:propertyset>\n\n\r\n"
{:Shuffle=>"0"}
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<Repeat>0</Repeat>\n</e:property>\n</e:propertyset>\n\n\r\n"
{:Repeat=>"0"}
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<Repeat>1</Repeat>\n</e:property>\n</e:propertyset>\n\n\r\n"
{:Repeat=>"1"}
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<Id>8</Id>\n</e:property>\n</e:propertyset>\n\n\r\n"{:Id=>"8"}

"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<Id>9</Id>\n</e:property>\n</e:propertyset>\n\n\r\n"
{:Id=>"9"}
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<Id>10</Id>\n</e:property>\n</e:propertyset>\n\n\r\n"{:Id=>"10"}

{:Id=>"11"}
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<Id>11</Id>\n</e:property>\n</e:propertyset>\n\n\r\n"
"<e:propertyset xmlns:e=\"urn:schemas-upnp-org:event-1-0\">\n<e:property>\n<Id>12</Id>\n</e:property>\n</e:propertyset>\n\n\r\n"
{:Id=>"12"}

@sidoh
Copy link
Owner

sidoh commented Dec 30, 2017

That's the error I'd expect to see if your callback tries to map over a string. The NoOpParser returns the raw XML string sent in the event. This is what we discussed, isn't it?

@arjunmenon
Copy link
Author

Yeah. I guess.
I expected a Nokogiri object so it could be pretty parsed.
This is cool then. Would work.

@arjunmenon
Copy link
Author

arjunmenon commented Dec 30, 2017

Further looking into your code, its much modular. What I had was a DefaultEventParser without any explicit property.
This is better, in a sense.

--
I guess you can update Readme to mention it can do Openhome and other Linn DS devices as well.

@sidoh
Copy link
Owner

sidoh commented Dec 30, 2017

Sweet. So this solves your problem?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants