Sha256: 0dae9c1bea2ff3272f6ec9e329ae89ca391999d8839d8e4df2a1969ec492b2b1
Contents?: true
Size: 898 Bytes
Versions: 3
Compression:
Stored size: 898 Bytes
Contents
require 'rubygems' require 'qcmd' require 'json' puts "setting up server" # server must come first server = OSC::TCP::Server.new 52000 server.add_method(/.*/) do |message| ip_address = message.ip_address.sub(/\.\.\./, '') ts = Time.now.strftime('%Y-%m-%d %H:%M:%S') types = message.to_a.map(&:class).map(&:to_s).join(', ') args = message.to_a puts "[#{ts}] #{message.ip_address}:#{message.ip_port} -- #{message.address} -- [#{ types }] -- #{ args.inspect }" message.responder.send OSC::Message.new("/hello-to-you-too") end puts "starting server" thread = Thread.new do server.run end class MyClientHandler def handle message puts "[MyClientHandler] #{ message.address }" end end puts "setting up client" client = OSC::TCP::Client.new 'localhost', 52000, MyClientHandler.new puts "sending spam" client.send OSC::Message.new("/hello", "world") sleep 1 # thread.join
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
qcmd-0.2.0 | sample/tcp_server_and_client.rb |
qcmd-0.1.16 | sample/tcp_server_and_client.rb |
qcmd-0.1.16.pre2 | sample/tcp_server_and_client.rb |