Class: Robut::Plugin::Rdio::Server
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Robut::Plugin::Rdio::Server
- Defined in:
- lib/server/server.rb
Overview
A simple server to communicate new Rdio sources to the Web Playback API. The client will update Robut::Plugin::Rdio::Server.queue with any new sources, and a call to /queue.json will pull those new sources as a json object.
Class Attribute Summary collapse
-
.command ⇒ Object
A command list for the player to execute.
-
.domain ⇒ Object
The domain associated with
token
. -
.last_played_track ⇒ Object
Returns the value of attribute last_played_track.
-
.queue ⇒ Object
A list of items that haven’t been fetched by the web playback API yet.
-
.reply_callback ⇒ Object
A callback set by to Robut plugin so the server can talk to it.
-
.state_callback ⇒ Object
A callback for Hipchat Chat room to set the state of the robut.
-
.token ⇒ Object
The playback token for
domain
.
Instance Method Summary collapse
- #announce!(message) ⇒ Object
- #state!(message) ⇒ Object
- #track_is_not_the_same_as_last?(current_track) ⇒ Boolean
Class Attribute Details
.command ⇒ Object
A command list for the player to execute
22 23 24 |
# File 'lib/server/server.rb', line 22 def command @command end |
.domain ⇒ Object
The domain associated with token
. Defaults to localhost.
36 37 38 |
# File 'lib/server/server.rb', line 36 def domain @domain end |
.last_played_track ⇒ Object
Returns the value of attribute last_played_track.
44 45 46 |
# File 'lib/server/server.rb', line 44 def last_played_track @last_played_track end |
.queue ⇒ Object
A list of items that haven’t been fetched by the web playback API yet.
19 20 21 |
# File 'lib/server/server.rb', line 19 def queue @queue end |
.reply_callback ⇒ Object
A callback set by to Robut plugin so the server can talk to it
39 40 41 |
# File 'lib/server/server.rb', line 39 def reply_callback @reply_callback end |
.state_callback ⇒ Object
A callback for Hipchat Chat room to set the state of the robut
42 43 44 |
# File 'lib/server/server.rb', line 42 def state_callback @state_callback end |
.token ⇒ Object
The playback token for domain
. If you’re accessing Rdio over localhost, you shouldn’t need to change this. Otherwise, download the rdio-python plugin:
https://github.com/rdio/rdio-python
and generate a new token for your domain:
./rdio-call --consumer-key=YOUR_CONSUMER_KEY --consumer-secret=YOUR_CONSUMER_SECRET getPlaybackToken domain=YOUR_DOMAIN
33 34 35 |
# File 'lib/server/server.rb', line 33 def token @token end |
Instance Method Details
#announce!(message) ⇒ Object
95 96 97 |
# File 'lib/server/server.rb', line 95 def announce!() self.class.reply_callback.call() if self.class.reply_callback end |
#state!(message) ⇒ Object
91 92 93 |
# File 'lib/server/server.rb', line 91 def state!() self.class.state_callback.call() if self.class.state_callback end |
#track_is_not_the_same_as_last?(current_track) ⇒ Boolean
99 100 101 |
# File 'lib/server/server.rb', line 99 def track_is_not_the_same_as_last? current_track self.class.last_played_track != current_track end |