Skip to content

Instantly share code, notes, and snippets.

@levicole
Created May 16, 2010 22:25
Show Gist options
  • Select an option

  • Save levicole/403215 to your computer and use it in GitHub Desktop.

Select an option

Save levicole/403215 to your computer and use it in GitHub Desktop.
#! /usr/bin/env ruby
require 'rubygems'
require 'eventmachine'
require 'rbosa'
module MusicServer
def post_init
send_data(currently_playing)
close_connection
end
private
def currently_playing
"I am currently playing:\n#{itunes.current_track.name} by #{itunes.current_track.artist}\n"
end
def itunes
itunes ||= OSA.app("iTunes")
end
end
EventMachine::run do
host = '0.0.0.0'
port = 8080
EventMachine::start_server host, port, MusicServer
puts "Started Music Server on #{host}:#{port}"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment