Skip to content

Instantly share code, notes, and snippets.

@nbqx
Created May 16, 2011 05:32
Show Gist options
  • Save nbqx/973974 to your computer and use it in GitHub Desktop.
Save nbqx/973974 to your computer and use it in GitHub Desktop.
# -*- 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