Class: OSC::EMServer
- Inherits:
-
Object
- Object
- OSC::EMServer
- Defined in:
- lib/osc-ruby/em_server.rb
Instance Method Summary collapse
- #add_method(address_pattern, &proc) ⇒ Object
-
#initialize(port = 3333) ⇒ EMServer
constructor
A new instance of EMServer.
- #run ⇒ Object
Constructor Details
#initialize(port = 3333) ⇒ EMServer
Returns a new instance of EMServer.
15 16 17 18 19 |
# File 'lib/osc-ruby/em_server.rb', line 15 def initialize(port = 3333) @port = port setup_dispatcher @tuples = [] end |
Instance Method Details
#add_method(address_pattern, &proc) ⇒ Object
31 32 33 34 35 |
# File 'lib/osc-ruby/em_server.rb', line 31 def add_method(address_pattern, &proc) matcher = AddressPattern.new(address_pattern) @tuples << [matcher, proc] end |
#run ⇒ Object
21 22 23 24 25 26 27 28 29 |
# File 'lib/osc-ruby/em_server.rb', line 21 def run EM.error_handler{ |e| Thread.main.raise e } EM.run do EM::open_datagram_socket "0.0.0.0", @port, Connection end end |