Class: Bernstein::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/bernstein/server.rb

Class Method Summary collapse

Class Method Details

.configure!(options = {}) ⇒ Object



7
8
9
# File 'lib/bernstein/server.rb', line 7

def self.configure!(options = {})
  @options.merge!(options || {})
end

.startObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/bernstein/server.rb', line 11

def self.start
  OSC.run do
    @server = OSC::Server.new(@options[:port],@options[:host])
    if @options[:require_awks] 
      @server.add_pattern @options[:awk_address] do |*args|
        handle_awknowledgement(args[1])
      end
    end

    @timer = EventMachine::PeriodicTimer.new(@options[:poll_interval]) do 
      process_queued_messages
    end
    yield if block_given?
  end
end

.stopObject



27
28
29
30
# File 'lib/bernstein/server.rb', line 27

def self.stop
  @server.stop unless @server.nil?
  @timer.cancel unless @timer.nil?
end