require 'rubygems' require 'eventmachine' require 'socket' require 'osc_to_rca_dispatcher' module UdpServer def post_init Ccg.logger.info "... server started" end def receive_data(data) return unless(CcgRunner.instance.valve == :open) # RCA rca_dispatching = proc { begin my_dispatcher = CanControlsGateway::OscToRcaDispatcher.new data my_dispatcher.dispatch_rca rescue Exception => e puts " ## #{e}\n -> #{e.backtrace.join "\n "}" end } rca_callback = proc { |result| } EventMachine::defer rca_dispatching, rca_callback end def unbind Ccg.logger.info "UdpServer stopped" end end