Class: TuioClient
Instance Attribute Summary collapse
-
#tuio_cursors ⇒ Object
readonly
Returns the value of attribute tuio_cursors.
-
#tuio_objects ⇒ Object
readonly
Returns the value of attribute tuio_objects.
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ TuioClient
constructor
A new instance of TuioClient.
- #start ⇒ Object
- #tuio_cursor(id) ⇒ Object
-
#tuio_object(id) ⇒ Object
getters #.
Constructor Details
#initialize(args = {}) ⇒ TuioClient
Returns a new instance of TuioClient.
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 51 52 53 54 |
# File 'lib/tuio_client.rb', line 21 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_cursors ⇒ Object (readonly)
Returns the value of attribute tuio_cursors.
15 16 17 |
# File 'lib/tuio_client.rb', line 15 def tuio_cursors @tuio_cursors end |
#tuio_objects ⇒ Object (readonly)
Returns the value of attribute tuio_objects.
15 16 17 |
# File 'lib/tuio_client.rb', line 15 def tuio_objects @tuio_objects end |
Instance Method Details
#start ⇒ Object
56 57 58 59 60 |
# File 'lib/tuio_client.rb', line 56 def start Thread.new do @osc.run end end |
#tuio_cursor(id) ⇒ Object
70 71 72 |
# File 'lib/tuio_client.rb', line 70 def tuio_cursor( id ) @tuio_cursors[id] end |
#tuio_object(id) ⇒ Object
getters #
66 67 68 |
# File 'lib/tuio_client.rb', line 66 def tuio_object( id ) @tuio_objects[id] end |