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.



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
49
50
# File 'lib/tuio-ruby/tuio_client.rb', line 17

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

  @tuio_objects = { }
  @tuio_cursors = { }
  
  @osc = OSC::SimpleServer.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.



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

def tuio_cursors
  @tuio_cursors
end

#tuio_objectsObject (readonly)

Returns the value of attribute tuio_objects.



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

def tuio_objects
  @tuio_objects
end

Instance Method Details

#startObject



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

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

#tuio_cursor(id) ⇒ Object



66
67
68
# File 'lib/tuio-ruby/tuio_client.rb', line 66

def tuio_cursor( id )
  @tuio_cursors[id]
end

#tuio_object(id) ⇒ Object

getters #



62
63
64
# File 'lib/tuio-ruby/tuio_client.rb', line 62

def tuio_object( id )
  @tuio_objects[id]
end