Sha256: 0d03374f17207a21834a2bcbcb6ac0e702162b2a4f0b3c9cdfd1738ab42f0b7f
Contents?: true
Size: 1.18 KB
Versions: 2
Compression:
Stored size: 1.18 KB
Contents
#!/usr/bin/env ruby require 'xmpp4r' require 'xmpp4r/roster' require 'xmpp4r/discovery' require 'xmpp4r/caps' require 'xmpp4r/tune' # # Echo tunes received via XEP-0118 User Tune notifications # # See Jabber::UserTune::Helper for the gory details # if ARGV.length != 3 puts "Usage: ruby tune_client.rb <jid> <pw> <tune-playing-jid>" exit 1 end jid = ARGV[0] pw = ARGV[1] dj_jid = ARGV[2] #Jabber::debug=true cl = Jabber::Client.new(Jabber::JID.new(jid)) cl.connect cl.auth(pw) # PEP (XEP-0163 says we need: # - a 'both' subscription to the dj # - told the server that we support the '...tune+notify' feature # before we can receive events roster = Jabber::Roster::Helper.new(cl) roster.add_subscription_request_callback(0, nil) do |item,pres| roster.accept_subscription(pres.from) end caps = Jabber::Caps::Helper.new(cl, [Jabber::Discovery::Identity.new('client', nil, 'pc')], [Jabber::Discovery::Feature.new('http://jabber.org/protocol/tune+notify')] ) t = Jabber::UserTune::Helper.new(cl, dj_jid) t.add_usertune_callback do |tune| puts "from:#{dj_jid} tune:#{tune.artist} plays #{tune.title}" end p = Jabber::Presence.new() p.type = :subscribe p.to = dj_jid cl.send p Thread.stop
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
bryanl-xmpp4r-0.3.2 | data/doc/xmpp4r/examples/basic/tune_client.rb |
heipei-xmpp4r-0.3.2 | data/doc/xmpp4r/examples/basic/tune_client.rb |