Sha256: 06a8f48064d03c8326609f4c54d072f91d1a4316886eba7276194cb077d74653

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

require 'qcmd'

require 'rubygems'
require 'json'

# try it out

qlab = OSC::TCP::Client.new 'localhost', 53000

def receive(rcv)
  if rcv
    rcv.each do |osc_message|
      begin
        response = JSON.parse(osc_message.to_a.first)

        address  = response['address']
        data     = response['data']
        status   = response['status']

        puts address

        if status
          puts "status -> #{ status }"
        end

        if data
          puts JSON.pretty_generate(data)
        end
      rescue => ex
        puts "parsing response failed: #{ ex.message }"
      end
    end
  else
    puts 'no response...'
  end
end

msg  = OSC::Message.new '/workspaces'
qlab.send(msg) do |response|
  receive(response)
end

# don't always expect a reply
msg = OSC::Message.new '/alwaysReply', 0
qlab.send(msg) do |response|
  receive(response)
end

# non-responsive command
msg  = OSC::Message.new '/workspace/65E9D86D-87DD-4CB1-A659-6584BAE57AB2/go'
qlab.send(msg) do |response|
  receive(response)
end

# always expect a reply
msg = OSC::Message.new '/alwaysReply', 1
qlab.send(msg) do |response|
  receive(response)
end

# non-responsive command is now a responsive command
msg  = OSC::Message.new '/workspace/65E9D86D-87DD-4CB1-A659-6584BAE57AB2/go'
qlab.send(msg) do |response|
  receive(response)
end


Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
qcmd-0.2.0 sample/tcp_qlab_connection.rb
qcmd-0.1.16 sample/tcp_qlab_connection.rb
qcmd-0.1.16.pre2 sample/tcp_qlab_connection.rb