Class: TuioClient

Inherits:
Object show all
Includes:
OSC
Defined in:
lib/tuio-ruby/tuio_client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = {}) ⇒ TuioClient

Returns a new instance of TuioClient.



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/tuio-ruby/tuio_client.rb', line 15

def initialize( args = {} )
  @port = args[:port] || 3333

  @tuio_objects = { }
  @tuio_cursors = { }

  @osc = OSC::Server.new(@port)

  @osc.add_method '/tuio/2Dobj' do |msg|
    args = msg.to_a

    case args.shift
    when "set"
      track_tuio_object( args )
    when "alive"
      keep_alive( :tuio_objects, args )
    when "fseq"
      # puts args
    end
  end

  @osc.add_method '/tuio/2Dcur' do |msg|
    args = msg.to_a

    case args.shift
    when "set"
      track_tuio_cursor args
    when "alive"
      keep_alive( :tuio_cursors, args )
    when "fseq"
      # puts args
    end
  end
end

Instance Attribute Details

#tuio_cursorsObject (readonly)

Returns the value of attribute tuio_cursors.



10
11
12
# File 'lib/tuio-ruby/tuio_client.rb', line 10

def tuio_cursors
  @tuio_cursors
end

#tuio_objectsObject (readonly)

Returns the value of attribute tuio_objects.



10
11
12
# File 'lib/tuio-ruby/tuio_client.rb', line 10

def tuio_objects
  @tuio_objects
end

Instance Method Details

#startObject



50
51
52
53
54
# File 'lib/tuio-ruby/tuio_client.rb', line 50

def start
  Thread.new do
    @osc.run
  end
end

#tuio_cursor(id) ⇒ Object



64
65
66
# File 'lib/tuio-ruby/tuio_client.rb', line 64

def tuio_cursor( id )
  @tuio_cursors[id]
end

#tuio_object(id) ⇒ Object

getters #



60
61
62
# File 'lib/tuio-ruby/tuio_client.rb', line 60

def tuio_object( id )
  @tuio_objects[id]
end