Class: OSC::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/osc-ruby/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(port) ⇒ Server

Returns a new instance of Server.



3
4
5
6
7
8
# File 'lib/osc-ruby/server.rb', line 3

def initialize(port)
  @socket = UDPSocket.new
  @socket.bind('', port)
  @matchers = []
  @queue = Queue.new
end

Instance Method Details

#add_method(address_pattern, &proc) ⇒ Object



20
21
22
23
24
# File 'lib/osc-ruby/server.rb', line 20

def add_method(address_pattern, &proc)
  matcher = AddressPattern.new(address_pattern)

  @matchers << [matcher, proc]
end

#runObject



10
11
12
13
14
# File 'lib/osc-ruby/server.rb', line 10

def run
  start_dispatcher

  start_detector
end

#stopObject



16
17
18
# File 'lib/osc-ruby/server.rb', line 16

def stop
  @socket.close
end