Class: Robut::Plugin::Rdio::Server

Inherits:
Sinatra::Base
  • Object
show all
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

Instance Method Summary collapse

Class Attribute Details

.commandObject

A command list for the player to execute



22
23
24
# File 'lib/server/server.rb', line 22

def command
  @command
end

.domainObject

The domain associated with token. Defaults to localhost.



36
37
38
# File 'lib/server/server.rb', line 36

def domain
  @domain
end

.last_played_trackObject

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

.queueObject

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_callbackObject

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_callbackObject

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

.tokenObject

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!(message)
  self.class.reply_callback.call(message) if self.class.reply_callback
end

#state!(message) ⇒ Object



91
92
93
# File 'lib/server/server.rb', line 91

def state!(message)
  self.class.state_callback.call(message) if self.class.state_callback
end

#track_is_not_the_same_as_last?(current_track) ⇒ Boolean

Returns:

  • (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