Created
May 16, 2011 05:32
-
-
Save nbqx/973974 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
# -*- coding: utf-8 -*- | |
%w(eventmachine osc-ruby uri readline).each{|x| require x} | |
server = 'localhost' | |
port = 12345 | |
uri = '/puts' | |
prompt = "> " | |
client = OSC::Client.new server, port | |
puts %q{ | |
_ _ _ | |
| (_) | | | |
| |___ _____ ___ ___ __| | ___ _ __ | |
| | \ \ / / _ \/ __/ _ \ / _` |/ _ \| '__| | |
| | |\ V / __/ (_| (_) | (_| | __/| | | |
|_|_| \_/ \___|\___\___/ \__,_|\___||_| | |
}+"osc cui client for #{server}:#{port}#{uri}\n\n" | |
EventMachine.run{ | |
Thread.start do | |
while buf = Readline.readline(prompt, true) | |
unless Readline::HISTORY.count == 1 | |
Readline::HISTORY.pop if buf.empty? || Readline::HISTORY[-1] == Readline::HISTORY[-2] | |
end | |
client.send(OSC::Message.new(uri,URI.escape(buf))) | |
end | |
end | |
trap("INT"){ | |
puts "\nbye!" | |
EventMachine.stop_event_loop | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment