Created
May 16, 2010 22:25
-
-
Save levicole/403215 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /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